I'm unable to pull issues of private repository under my account.
I've created personal access token with repo permissions.
Using this command to fetch issues :
curl -i https://api.github.com/repos/{owner}/{repo}/issues -H "Authorization: token {personal-access-token}"
But getting error :
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest/reference/issues#list-repository-issues"
}
Maybe check for the repository under the organization account; then you must use:
https://api.github.com/repos/{organization}/{repo}/issues
The full command:
curl -H "Authorization: token {personal-access-token}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/{organization}/{repo}/issues
Related
I have the latest gh CLI app. I set a GH_TOKEN. It seems to be working, because this works:
gh api --method GET -H "Accept: application/vnd.github.v3+json" "orgs/MyOrg/repos"
...it returns a few repos.
But this call returns a 404:
gh api --method GET -H "Accept: application/vnd.github.v3+json" "repos/MyOrg/MyRepo/actions/runners"
even though my (classic) token has full repo scope as well as read:org and manage_runners:org.
What I'm really trying to do is create a self-hosted runner, and this doesn't work either:
gh api --method POST -H "Accept: application/vnd.github.v3+json" "/repos/MyOrg/MyRepo/actions/runners/registration-token"
that also returns a 404. Any hints?
link for the docs is here and the curl command is:
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/teams
I've given personal access token as my Authorization but it throws as not found.
Any suggestions on how to get it? My repo was assigned to 3 teams even tho it throws not found
i'm the owner of the org and trued to hit with my PAC even tho its giving me the same 404 statusCode.
for example :
this is the link for getting the contributors but for teams i've this but it is giving me 404
I am trying to make a call https://api.github.com/repos/OWNER/REPO/actions/runners/registration-token with an users personal access token that has repo permissions.
To do so I am testing with:
curl -I -X POST -H "Authorization: token <OAUTH_TOKEN> Accept: application/vnd.github.v3+json" https://api.github.com/repos/<owner>/<repo-name>/actions/runners/registration-token which gives me Bad Credentials error
curl -I -H "Authorization: token <OAUTH_TOKEN>" https://api.github.com/users/<USER_NAME> ->
x-oauth-scopes: repo
x-accepted-oauth-scopes:
According to this: https://docs.github.com/en/rest/actions/self-hosted-runners I need to provide an oauth token with repo access.
If I curl the user curl -H "Authorization: token <OAUTH_REPO_TOKEN>" https://api.github.com/users/<USER>/repos -> []. But if I go to the repo and check settings -> Collaborators And Teams, the user is listed as part of the team with admin privledges, and I have also added an entry for the user directly.
Is there something I am missing? What permissions do I need to add to fix this?
I needed to call the API with a user name as well. For example:
curl -I -X POST -u <USER>:<OAUTH_REPO_TOKEN> -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/<owner>/<repo-name>/actions/runners/registration-token. Passing a -v option reveals that it was not setting a username, and causing github to reject the call.
I'm trying to get an auth-token to use the REST API from opensubtitles but when I send a request I recieve a 401 unauthorized
This is my curl request that I copied off their docs
curl -X POST "https://www.opensubtitles.com/api/v1/login" -d '{
"username": "username",
"password": "password"
}' \
-H "Accept: application/json" \
-H "Content-Type: application/json"
This is the response I got
{"message":"Error, Unauthorized","status":401}
At first, I thought it was a password error so I tried changing my password to login but it was still not working. Then I even tried to use my email as my username but it still didn't work.
I even tried to make a new account and login but I kept on recieving the same response.
I have a bitbucket cloud account. Under: https://id.atlassian.com/manage/api-tokens I have generated an API Token which I am trying to use in a REST call to upload
a public SSH key to my account. Based on:
https://docs.atlassian.com/bitbucket-server/rest/5.6.2/bitbucket-ssh-rest.html?utm_source=%2Fstatic%2Frest%2Fbitbucket-server%2F5.6.2%2Fbitbucket-ssh-rest.html&utm_medium=301#idm45427244388592
https://community.atlassian.com/t5/Answers-Developer-Questions/Bitbucket-REST-API-POST-using-token-instead-of-basic-auth/qaq-p/474823
I have tried:
curl -X POST -d '{"text":"ssh-rsa AAAAB3... me#127.0.0.1"}' -H "Authorization: Bearer ADasdaEeasAsd..." https://bitbucket.org/[my-account]]/rest/ssh/latest/keys
But when I run that I get:
{"type": "error", "error": {"message": "Access token expired. Use your refresh token to obtain a new access token."}}
I have tried to re-create the token and re-run the above command again - with the new token - but I get the same error.
Any suggestions?
Based on below answer and link I have now tried:
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer wxdrtblabla..." \
-d '{"key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKqP3Cr632C2dNhhgKVcon4ldUSAeKiku2yP9O9/bDtY myuser#bitbucket.org/myuser"}' \
https://api.bitbucket.org/2.0/users/myuser/ssh-keys
But I get the exact same error:
{"type": "error", "error": {"message": "Access token expired. Use your refresh token to obtain a new access token."}}
So still no luck. Also if I access:
https://api.bitbucket.org/2.0/users/[myuser]/ssh-keys
directly in a browser I get:
type "error"
error
message "This API is only accessible with the following authentication types: session, password, apppassword"
EDIT/ANSWERED: Based on the updated answer below I have no tried to create an app password and grant it account: read/write in bitbucket and it works. I run it with:
curl -v -u myuser:my-generated-app-password -X POST \
-H "Content-Type: application/json" \
-d '{"key": "ssh-rsa AAA....ro"}' \
https://api.bitbucket.org/2.0/users/myuser/ssh-keys
You're looking at Bitbucket Server documentation but using Bitbucket Cloud. (The giveaways: the "bitbucket-server" part of the doc path, and the "bitbucket.org" in the path where you're pushing your key.)
Check out https://developer.atlassian.com/bitbucket/api/2/reference/resource/users/%7Busername%7D/ssh-keys#post instead - that's the Bitbucket Cloud documentation to do what you're trying to do. Your URL will be more like https://api.bitbucket.org/2.0/users/[your-account]/ssh-keys.
EDIT: The error you received indicates the problem: you either need to make that call from within an existing session (i.e. from the GUI), use your password, or use an app password. I'd recommend the app password, since it's scoped, meant to be disposable, and won't let you log onto the GUI. Your curl call then becomes something like curl -u myuser:myapppassword -X POST -H "Content-Type: application/json" -d '{"key": "key content goes here"}' https://api.bitbucket.org/2.0/users/myuser/ssh-keys.