Imtiaz Hussain
Imtiaz Hussain

Reputation: 203

Can we get the name or details of Google Cloud Console project by using its credentials?

I am working on a Cloud Messaging project and I am getting the credentials of the Google Cloud Console project from a configuration file from front-end. Using those credentials I am generating the access/bearer token. Can we use the bearer token to get the details of that project. I mean to say can we get the name, project-id, project-number of a Google Cloud Console project by using its bearer-token by making an API call. Is there any specific API for this purpose.

Upvotes: 0

Views: 77

Answers (1)

John Hanley
John Hanley

Reputation: 81416

Given an Google Cloud Access Token you can call an endpoint to receive information about that token. The item of interest is the service account email address which then identifies the project.

Here is how to do it with curl. Replace TOKEN with the actual Access Token which is base64 encoded:

curl "https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=TOKEN"

You can also decode an Access Token. An Access Token is simply a Signed-JWT.

Upvotes: 2

Related Questions