You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following pry session demonstrates a succesful authorization flow for which #authorized? returns false.
[4]pry(main)> cli=Googl.::OAuth2.server(client_id,client_secret,"http://localhost:3000/google_plus")=>#<Googl::OAuth2::Server:0x0000000c3ba1d0@client_id="omited",@client_secret="omited"@redirect_uri="http://localhost:3000/google_plus">
[5]pry(main)> cli.redirect_uri=>"http://localhost:3000/google_plus"[6]pry(main)> cli.authorize_url=>"https://accounts.google.com/o/oauth2/auth?client_id=<<ommited>>&redirect_uri=http://localhost:3000/google_plus&scope=https://www.googleapis.com/auth/urlshortener&response_type=code"# At this point I copied and pasted the code in the browser, authorized and then copied the params[:code] returned to paste in the following call[7]pry(main)> cli.request_access_token("<<params[:code] returned>>")CLI.=> #<Googl::OAuth2::Server:0x0000000c3ba1d0@access_token="<<omited>>",@client_id="<<omited>>",@client_secret="<<omited>>",@expires_at=2015-10-2016:48:24 +0200,@expires_in=3600,@redirect_uri="http://localhost:3000/google_plus",@refresh_token=nil>
[8]pry(main)> cli.authorized?=>false# hmm, even though we have the access token with 1hour validity
At this point any calls to the api (cli.history) would fail silently, and given the delay for the returning call, I suspect without any network request.
After playing around a little bit I decided to monkey patch the authorized? method:
After further checking, my issue was caused because #authorized? checks for refresh_token presence, even though my OAuth flow resulted in a valid access token, allowing me to succesfully perform requests. I wanted to know before submitting any pull requests if this is intentional or justified in some way, as I'm not really familiar with the details of the goo.gl API.
I'd gladly make a pull request to remove the check on the refresh_token presence, or maybe only check for the presence of the refresh_token in case the token has expired.
Thanks
The text was updated successfully, but these errors were encountered:
The following pry session demonstrates a succesful authorization flow for which #authorized? returns false.
At this point any calls to the api (cli.history) would fail silently, and given the delay for the returning call, I suspect without any network request.
After playing around a little bit I decided to monkey patch the authorized? method:
After further checking, my issue was caused because #authorized? checks for refresh_token presence, even though my OAuth flow resulted in a valid access token, allowing me to succesfully perform requests. I wanted to know before submitting any pull requests if this is intentional or justified in some way, as I'm not really familiar with the details of the goo.gl API.
I'd gladly make a pull request to remove the check on the refresh_token presence, or maybe only check for the presence of the refresh_token in case the token has expired.
Thanks
The text was updated successfully, but these errors were encountered: