16

update: even such a request get bad credential ==>

curl -H "Authorization: token [token]" https://api.github.com

===============

I made a request for GitHub OAuth like this in my iOS app:

URL: https://github.com/login/oauth/authorize,
params: client_id: ****, redirect_uri: app_url, scope: "repo", state: "0"

After redirection from Safari I get a code. I need to access to two things:

  1. User data, like email and etc. Also updating user data.
  2. List of repositories and commits in public and private repos.

I make following requests:

URL: https://api.github.com/user, get and patch Header: Authorization: token [code]

URL: https://api.github.com/repos/:username/:repoName
Header: Authorization: token [code]

But unfortunately, I get the following error:

401, Unauthorized
{
    "message": "Bad credentials",
    "documentation_url": "https://developer.github.com/v3"
}

What is the problem and how can I solve it?

2 Answers 2

8

As it is said in this blob (NOT the main documentation) you have to exchange token (which is temporary) with a bearer token via this api:

the main api

Here comes the documentation for others: Github blob documentation

Sign up to request clarification or add additional context in comments.

1 Comment

Can you/someone give some supporting code snippet and clarification on this answer
5

The following curl command works: curl -u your_git_name:your_personal_access_token https://api.github.com/user

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.