Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Cloud run service auth2 token server to server

Hello,

i have developed a flask rest api that create dinamically a job using cloud run admin api.

Now i need to creare a rest api that when is called, create a scheduler of a job using Cloud Scheduler Api.

I have seen that the cloud scheduler want a auth2 token web application. Is there any way to generate a correct token auth2 to use into cloud scheduler api to schedule a job, without a google login interface?

Thanks

 

0 2 436
2 REPLIES 2

Hello @snef 

Welcome to Google Cloud Community!

If you want to generate an OAuth2 token to use with the Cloud Scheduler API without a Google login interface, you can try these following step-by-step guides with reference and supported documentation:

1. Set up a Service Account.
2. Generate Service Account Key by following the instruction.
3. Install Required Libraries

pip install google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client

4. Write Python Code to Generate OAuth2 Token.
5. Use the Generated Access Token.

6. Contact Google Cloud Support  if the above steps don't help.

Thank you.

Hi julia, thanks for your reply.

I have done all this steps but the result is always this

Failed to create job: {
  "error": {
    "code": 401,
    "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}

The user account joined with key have the admin scheduler role, i will send a mail to support.