Google OAuth 2 API support. #210

Closed
wants to merge 5 commits into
from

Projects

None yet

10 participants

@lsolova
lsolova commented Jan 2, 2012

Hello Pablo,

I have to support Google OAuth 2 login in my project. I added this API to the apis, and there are some additional changes too. First of all the grant_type is a required parameter in OAuth 2, so it could be set via API objects yet. The Google API requires some changes in request parameter handling, because they wanna use POST instead of GET. So I merged body parameters and querystring parameters, and only the Verb defines the request method. The Google access_token answer contains whitespaces between the name and the colon - I changed the regex pattern of JsonTokenExtractor to tolerate this.

Please, check my changes, and if you find them useful, then pull it back please in the main project. I tested the new version against Facebook, Live and Google via OAuth 2 interfaces.

Thanks for this great library!

Regards,
Laszlo

@netbrain
netbrain commented Jan 7, 2012

I wrote a patch myself for Oauth 2 and sent it to pablo right before xmas. Code looks pretty identical. guess i should have made a pull request like you so it would have been publicly available. sorry for that :)

@pledbrook

Will this make it into Scribe?

@santiagopoli

It would be nice if this functionality make its way into scribe.

@yincrash

For you guys who want it before it gets included into scribe, I wrote a version that is self contained and requires no modification to the library (so you can include it in your project now). This doesn't handle the "state" parameter, because it's optional and requires, well, state. In my app, it's handled outside the library.

https://gist.github.com/2465453

Wrote it w/o looking at Isolova's version. Ideally, the library itself should be updated to take into account the current state of the OAuth 2.0 spec (v25), such as the "grant_type" parameter which is required to be "authorization_code" for the authorization code grant flow (4.1.3), and handling the POST verb for the access token request. See my extension of OAuth20ServiceImpl at the bottom of the gist.

@mebibou
mebibou commented Jun 6, 2012

I've taken the Google2Api code from yincrash, and tried to retrieve the Google Contacts with it, but I always get an error 401 like 'There was an error in your request'. Has anyone been able to make the Google Contacts work? I was trying to access https://www.google.com/m8/feeds/contacts/default/full with my freshly retrieve oauth 2.0 tokens, but no luck. I've also been trying using the gdata library but I have a 'No authentication header information'.

Note: I have tried the same things by using the GoogleApi instead and it works, these errors only appear with oauth 2.0

@stackmagic

a method that's named getByteBodyContents uses query-string params? I don't think that's what it's intended to do? Does it break any of the gazillion other apis that scribe supports?

@benmccann

@mebibou I was able to retrieve Google Contacts using the code provided by @yincrash

@benmccann

Is there a reason this was closed and not merged yet? I'd really like to see it in Scribe.

@fernandezpablo85
Collaborator

I closed most tickets today, here's the reason:

https://github.com/fernandezpablo85/scribe-java/wiki/Scribe-scope-revised

Sorry :(

@literakl

Pity. At least I will learn github forking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment