Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Missing authorization code after admin token has expired #4

Closed
sush opened this issue Jan 4, 2015 · 4 comments
Closed

Missing authorization code after admin token has expired #4

sush opened this issue Jan 4, 2015 · 4 comments

Comments

@sush
Copy link

sush commented Jan 4, 2015

After a first sign in to Gaps with the domain's admin account and a successful fetch of the associated groups, the app crashes with the following stacktrace:

/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/signet-0.5.1/lib/signet/oauth_2/client.rb:906:in `generate_access_token_request': Missing authorization code. (ArgumentError)
    from /.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/signet-0.5.1/lib/signet/oauth_2/client.rb:930:in `fetch_access_token'
    from /.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/signet-0.5.1/lib/signet/oauth_2/client.rb:956:in `fetch_access_token!'
    from /dev/gaps/lib/gaps/db/user.rb:241:in `do_refresh'
    from /dev/gaps/lib/gaps/db/user.rb:101:in `client'
    from /dev/gaps/lib/gaps/requestor.rb:135:in `user_client'
    from /dev/gaps/lib/gaps/requestor.rb:143:in `get_client'
    from /dev/gaps/lib/gaps/requestor.rb:155:in `request'
    from /dev/gaps/lib/gaps/requestor.rb:193:in `block in request_all'
    from /.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/core_ext/range/each.rb:7:in `each'
    from /.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/core_ext/range/each.rb:7:in `each_with_time_with_zone'
    from /dev/gaps/lib/gaps/requestor.rb:189:in `request_all'
    from /dev/gaps/lib/gaps/requestor.rb:42:in `group_list'
    from /dev/gaps/lib/gaps/db/group.rb:177:in `refresh'
    from /dev/gaps/lib/gaps/db/group.rb:157:in `boot'
    from bin/gaps_server.rb:366:in `block in main'
    from /.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `call'
    from /.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'

I can't figure why but It seems that the refresh token isn't set in client.authorization when fetch_access_token! is called.

Any idea on the root cause?

Anyway, thanks for this great tool, very helpful in managing our mailing lists :)

@sush sush changed the title Missing authorization code error after admin token has expired. Missing authorization code after admin token has expired Jan 4, 2015
@alvinlai
Copy link
Contributor

alvinlai commented Jan 4, 2015

Hi @sush, I suspect you've previously connected gaps, the refresh_token only seems to be returned on the first connect, where you'll see this:

screen shot 2015-01-04 at 3 10 33 pm

You could fix this by temporarily adding:

authorization_options[:approval_prompt] = :force

after https://github.com/stripe/gaps/blob/master/bin/gaps_server.rb#L117

sauce: http://developers.google.com.resnip.com/accounts/docs/OAuth2WebServer/U0lSCa0.html?#alvin--CTimDTI

@gdb would it be a good idea to set that authorization_option if the lister doesn't have a refresh_token set?

@alvinlai
Copy link
Contributor

alvinlai commented Jan 4, 2015

You can use my branch:

https://github.com/alvinlai/gaps/tree/force-refresh-token-first-time

to get the refresh_token persisted for the first time

specifically:

alvinlai@5bfec15

@gdb
Copy link
Contributor

gdb commented Jan 5, 2015

@alvinlai: Good find! Merging in your change.

@sush
Copy link
Author

sush commented Jan 5, 2015

Thanks @alvinlai!

@gdb gdb closed this as completed Jan 5, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants