My Business
3.6K members online now
3.6K members online now
For developers who are using the Google My Business API to manage locations
Guide Me
star_border
Reply

Authorization using refresh token

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hey,

 

I am having refresh token, client_id, client_secret and developer_token. I want to initialize an instance of Mybusiness class using these above information. Is it possible to do so using gmb's java client library. I tried navigating the documentation on oauth/gmb, but could not find a way. 

 

Can anybody give me reference to document/code where this is being done?

 

 

 

1 Expert replyverified_user

Re: Authorization using refresh token

Google Employee
# 2
Google Employee

Hi @Siddharth M,

 

There’s a guide on our API documentation website for setting up the Java Client Library.

 

When you have an OAuth 2.0 client ID for authentication and authorization, you should use the OAuth 2.0 installed application flow and persist the refresh token. This way, your application will always be able to request a new access token when necessary. This process requires a user to manually authorize the application during the OAuth 2.0 installed applications flow only once.

 

If you use the access_type=offline parameter during the authorization code flow, you can retain a long-lived refresh token, which is typically received along with the access token. If you are using our Java sample app, the following is a Java code snippet for persisting the refresh token:

   // set up authorization code flow

   GoogleAuthorizationCodeFlow flow =

       new GoogleAuthorizationCodeFlow.Builder(

               httpTransport,

               JSON_FACTORY,

               clientSecrets,

               Collections.singleton("https://www.googleapis.com/auth/plus.business.manage"))

           .setDataStoreFactory(dataStoreFactory)

           .setAccessType("offline")

           .setApprovalPrompt("force")

           .build();

   // authorize

   return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");

 

I hope this helps get you started.

 

Thanks,

Terry

Authorization using refresh token

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

same probloem, but javascrit and nodejs.

 

Re: Authorization using refresh token

Google Employee
# 4
Google Employee

Hi @Jesse A,

 

I’ve provided a solution for your problem in this thread.

 

Thanks,

Terry