3
votes

I'm trying to get a user's email address from GitHub, and I'm just testing the process using Postman. I have a token that has user and user:email scopes, and hitting https://api.github.com/user gives me the user's info. Private emails aren't visible at that endpoint, so I'm also hitting https://api.github.com/user/emails. The email endpoint gives me a 404.

The response headers that come back with the 404 seem to say I have the right perms:

X-Accepted-OAuth-Scopes →user, user:email

There is an email set up in the account. What could be causing the 404?

Update: The troubleshooting page suggests that third-party application restrictions might be to blame. The account I'm trying to access is part of an organization, but "Third-party application access policy" in the organization is set to "No restrictions".

2

2 Answers

3
votes

The main issue I was having here was looking at the wrong header. X-Accepted-OAuth-Scopes is the list of scopes the endpoint wants to see. X-OAuth-Scopes is the list of scopes you actually have. That was empty because of a bug in the token-creating code.

2
votes

I've been facing similar issue for past several hours. Played with X-OAuth-Scopes and etc. Turned out my https://github.com/login/oauth/authorize url was malformed and didn't have necessary scopes in it.

Advise: be sure you are receiving required scope together with your access_token response:

{"access_token":"47f31841f3b532fc4aafb3ccd924bfd0145c1c24","token_type":"bearer","scope":"user"}

In my case it was empty.