This forum is now read-only. Please use our new forums at discuss.codecademy.com.

OAuth2 Forum

View Course » View Exercise

2305 points
5693b6aef50c68020700022d_909939302
Submitted by
Yathi
over 4 years ago

Something wrong with this exercise.

This was my code:

require 'httparty'
require 'json'

token = "e6a75d6b6d7b0fdd0eee93fd3c141d808852a0e9"
request_headers = {"Authorization" => "token: #{token}"}

response = HTTParty.get "https://api.github.com", 
         :headers => request_headers

puts response

I get this as the response:

{"message"=>"Bad credentials"}
nil

The reason I am checking just response is because response.headers["X-OAuth-Scopes"] gave me a nil as the response even though the code passed.


3 votes

permalink

try this

require 'httparty'
require 'json'

token = "e6a75d6b6d7b0fdd0eee93fd3c141d808852a0e9"

response = HTTParty.get "https://api.github.com",
:headers => {
"Authorization" => "token #{token}",
"User-Agent" => "codecademy"

}

print response.headers["X-OAuth-Scopes"]

982 points
Picture
Submitted by
Vasilis Spilka
about 4 years ago

3 Comments

3790335aba1e1e2d72afb2a043f6e8ef?s=140&d=retro zechino almost 4 years ago

Separate the 'requires'

595685279ad7f5be150002c6_951960925 mezbah alam almost 4 years ago

its work .but i can't understand!!

53c963d9282ae3e81b00051f_841453022 Michael Rizzo almost 3 years ago

The api behind the lesson is is broken. copy and paste the example and seperate the requires.