End-to-end example

Consider this scenario. We want to see how many private repositories our "API Padawan" user has on github.com. We discover that calling the "/user" method with a token with no scopes does not returned the information we want.

Let's make a call to the method and inspect the headers to determine what scope we need on our token.


Add the token to the request headers on line 17.

Modify the return value of the new check_accepted_scopes method to return an array of the accepted scopes for this API method on line 21.

Modify line 26 to accept an array of scopes and pass that in the post_body hash.

Stuck? Get a hint! Hint
Get live, fast support from Codecademy Advisors when you get stuck. Learn more.

Change line 17 to headers = {"Authorization" => token #{@token}"}.

Return the scopes with response.headers["X-Accepted-OAuth-Scopes"].split(",").map(&:strip).

Change the post_body assignment to: post_body => {:scopes => scopes}