Need help implementing OAuth 2.0 authorization

120 views
Skip to first unread message

dds.d...@gmail.com

unread,
Oct 30, 2014, 6:39:19 PM10/30/14
to google-oauth...@googlegroups.com
Hello,

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 https://github.com/googleads/googleads-dfa-reporting-samples/tree/master/java.

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.

Thanks,
Yury

Daniel Wang

unread,
Nov 7, 2014, 11:01:44 AM11/7/14
to google-oauth...@googlegroups.com
Hi,

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
Forward
0 new messages