Need help implementing OAuth 2.0 authorization

Skip to first unread message

Oct 30, 2014, 6:39:19 PM10/30/14

I am trying to port our authorization code to OAuth 2.0 by changing to GoogleAuthorizationCodeFlow which sets data store factory similar to the example here

The problem I am facing is that after above changes new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user") code starts up browser with authorization page. This is different, and in our case, undesired behavior then it used to be when CredentialStore was used and the call to get credential silently worked without starting browser. This is an unattended, server side batch service, which can't have any access to browser. Please advice what should be done to address this issue.


Daniel Wang

Nov 7, 2014, 11:01:44 AM11/7/14

We have provided multiple auth flows [1] that are suited for different types of applications. In your case, you would want to use the Service Account auth flow [2], which allows authorizes your application to access data that's owned by itself, not end users. Service account flow doesn't involve browsers.

If you really want to access user's data, with the consent from the user of course, you may still use Installed Application flow, but in your case, you will use the AbstractPromptReceiver [3], which allows you to copy/paste a auth code into a console (e.g. ssh). Hopefully you need to do this only once if you've given a data store instance.

For example:

class MyVerificationCodeReceiver extends AbstractPromptReceiver {

new AuthorizationCodeInstalledApp(flow, new MyVerificationCodeReceiver()).authorize("user")

Reply all
Reply to author
0 new messages