fetch_access_token! in Google-API — "Missing authorization code."

Ich bin mit dem Google-API-Ruby-Client erhalten Sie Zugang zu den Kalendern der Nutzer.

Bekomme ich Zugriff mit:

  client_id: "xxxxx"
  client_secret: "xxxxx"
  access_type: "offline"
  approval_type: ""
  scope: "https://www.google.com/calendar/feeds/https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/calendar"
  callback_path: "/app/oauth_response"

  provider :google_oauth2, GOOGLE_API['client_id'], GOOGLE_API['client_secret'], 
            { access_type: GOOGLE_API['access_type'], 
              approval_prompt: GOOGLE_API['approval_prompt'], 
              scope: GOOGLE_API['scope'], 
              callback_path: GOOGLE_API['callback_path'],
              path_prefix: GOOGLE_API['path_prefix']}

Wenn die Antwort kommt zurück, es hat eine refresh-token, access token, expired_at, etc. Ich bin dann in der Lage, um API-Anfragen mit dem access code. Aber einmal, dass der Zugangscode abgelaufen ist (nach einer Stunde), ich glaube, ich muss der refresh-token, um ein neues Zugriffstoken, richtig?

Hier ist der Anruf, den ich mache:

HTTParty.get('https://www.google.com/calendar/feeds/default/owncalendars/full', :query => {:alt => "jsonc", :access_token => access_token})

Was mir sagt, dass mein token abgelaufen. Also versuche ich ein neues zu erhalten.
Aber wenn ich versuche zu tun, dass ich dieses:

@client.authorization.fetch_access_token!
ArgumentError Exception: Missing authorization code.

Sehe ich, dass in meinem @client object, @code=nil. Ich gehe davon aus, dass das, was gesetzt werden muss, aber ich bekomme nicht einen 'code' - Eigenschaft zurück von meiner ersten Anfrage.

Wie Schaffe ich es, dass code, oder wenn ich brauche es nicht, was mache ich falsch?
Danke!

InformationsquelleAutor 99miles | 2012-04-09
Schreibe einen Kommentar