0

I am trying to create a process that will create users in g suite using Java. The Google documentation is a little bit confusing for me but I manage to create a G Suite user on localhost. The problem is when I deploy de application on a specific id the redirect URL for auth doesn't work anymore.

I manage to do this by adapting this quick start: https://developers.google.com/admin-sdk/directory/v1/quickstart/java

My question is related to google popup. How can I prevent this popup, is there a way to use a simple secret key?

If not how can I configure my application from google console to allow multiple sites to receive the auth token?

Thank you

Adrian
  • 947
  • 1
  • 12
  • 24

1 Answers1

1

You cannot create new users in Gsuite without OAuth2. When you run the quickstart program it will open a new tab and asked for Authentication & Authorization. Once you complete the Authorization it will store the token in your project folder. When you add users to Gsuite(you need to write code using documentation) it will use that token (Access token). It will not ask for authorization again. So you need to authorize your application in order to create users in Gsuite. In case you delete that token, it will ask to Authorize the application.

Satheeshkumar
  • 75
  • 3
  • 12
  • But that token will not expire sometime? – Adrian Nov 18 '19 at 07:11
  • 1
    Access tokens are periodically expire. It refreshes itself if you use google client library and if you request offline access (.setAccessType("offline") in getCredentials() method). You need to store the token in a secure, long-lived location and no need to worry about token expiration. Refer this webpage for details information https://developers.google.com/identity/protocols/OAuth2WebServer#offline – Satheeshkumar Nov 18 '19 at 07:28
  • 1
    Token will be expired in such case if the user removed access of your application in their Gmail account settings. It also can be done by programmatically using API. If the user removes access to your application in Gmail Account settings, authorization needs to be done again. If you change the scope, it will ask for authorization. – Satheeshkumar Nov 18 '19 at 07:32