Determine scopes for given GitHub Token

If you have a given token from GitHub and you want to know which scopes it has you have to check the Headers. Just use the token for any resource on the GitHub API and double check the headers of the response. In the headers the “x-oauth-scopes” field tells you the which scopes the token has.

Here is a small example with Ruby and HTTParty.


response = HTTParty.get("https://api.github.com/user?access_token=#{token}", :headers => {"User-Agent" => A_USER_AGENT } )
response.headers['x-oauth-scopes']

If you HTTParty, party hard! 😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s