1

I'm trying to upload files to a Google Cloud Storage bucket from a Ballerina application. Right now, the only way I’ve found to authenticate is by manually generating an access token using a service-account.json file from the Google Cloud Console.

My question: Is there a way in Ballerina to:

  • Load a service account JSON key
  • Request a Google OAuth 2.0 access token
  • Use that token to interact with GCS APIs

If so, what’s the right way to do this using Ballerina’s built-in modules?

What I tried:

  • I used Ballerina’s http to send a POST request to GCS.
  • I passed an access token (manually generated via gcloud auth application-default print-access-token) in the Authorization header.
  • It works, but the access token expires quickly and must be regenerated manually.

What I want: I’d like to programmatically authenticate using a service account key or some supported method in Ballerina, so the token can be generated or refreshed within the app.

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.