Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get email from GitHub API

Tags:

github-api

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".

like image 770
TimK Avatar asked Oct 30 '25 01:10

TimK


1 Answers

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.

like image 115
Artsiom Miklushou Avatar answered Nov 01 '25 14:11

Artsiom Miklushou