Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting results from Garb using OAuth token returns hard to understand error #8

Closed
jasperkennis opened this issue Nov 24, 2012 · 5 comments

Comments

@jasperkennis
Copy link

I'm having a hard time getting data from Google using an OAuth authorized token. I have the following:

Garb::Session.access_token = current_user.google_api_token
raise Garb::Management::Account.all.to_yaml

I'm aware improvements could be made all over the place, but that aside I'm getting some pretty unexpected result:

undefined method `get' for "ya29.AHES6ZSGqK4BMwuvzQvYCK5JG1Y...":String

I'm getting the feeling I'm doing something wrong here but I can't figure out what. I have looked at both the source and the code but that's not helping. The curent_user.google_api_token I generate using omniauth-google-oauth2. Help would be greatly appreciated!

@Sija
Copy link
Owner

Sija commented Nov 24, 2012

Indeed, Garb::Session.access_token should be an instance of OAuth2::AccessToken instead of a raw String.

@jasperkennis
Copy link
Author

Hm, would be nice if Garb would handle the initialization of the AccssToken object. I might invest a few hours into that next tuesday.

@Sija
Copy link
Owner

Sija commented Nov 25, 2012

That I think wouldn't be feasible as Garb doesn't "know" enough to initialize OAuth2::AccessToken.
This should be done by yourself by providing things like OAuth2::Client instance and appropriate options to the initializer.

@jasperkennis
Copy link
Author

Ah, oke, seems legit. Maybe the documentation in the readme could use some clarification on using OAuth access tokens with Garb. I think this issue should be closed now, thanks for your quick reply!

@jasperkennis
Copy link
Author

Just a side note, a good way to generate that token is suggested on StackOverflow by Brandon Tilley: http://stackoverflow.com/questions/5675029/how-to-use-omniauth-to-make-authenticated-calls-to-services

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants