rizen/Facebook-Graph

Improve error message on expired authorization

Ovid opened this issue · 1 comments

Ovid commented

I was trying to figure out why I kept getting a "Bad request" when I tried $fb->request_access_token($code). I bit of debugging showed the following in the Facebook::Graph::AccessToken::Response (most items trimmed so we can see the actual issue):

0  Facebook::Graph::AccessToken::Response=HASH(0x274f9c0)
   'response' => HTTP::Response=HASH(0x2f2ad80)
      '_content' => '{"error":{"message":"This authorization code has expired.","type":"OAuthException","code":100}}'
      '_headers' => HTTP::Headers=HASH(0x2f2ad08)
         'www-authenticate' => 'OAuth "Facebook Platform" "invalid_code" "This authorization code has expired."'
      '_msg' => 'Bad Request'
      '_protocol' => 'HTTP/1.1'
      '_rc' => 400
      '_request' => HTTP::Request=HASH(0x2863430)

It appears that both the www-authenticate and the _content keys have very relevant information ("This authorization code has expired.") which would have led to faster debugging.

Cheers,
Ovid

improved in 1.0700