0
votes

Is it possible to create an OAuth client (https://developers.google.com/identity/protocols/OAuth2) using a script (gcloud or any library)?

Google recommended way (https://developers.google.com/identity/protocols/OAuth2WebServer#creatingcred) is to manually create from https://console.developers.google.com/apis/credentials.

I have multiple apps with different url_redirects like https://a.domain.com, https://b.domain.com https://c.domain.com, https://d.domain.com, this subdomain list is large to manage manually.

I want to automate this process for my use case. I'm not able to find any library to do this.

Update: Endpoint used by GCP console https://clientauthconfig.clients6.google.com/v1/clients and there is related permission also "clientauthconfig.clients.create" but there is no API provided for it.

2
I'm in the same position but coming from the google terraform provider. It is possible to create the oauth client but useless for me as I need to also setup the url redirects. So the API stops at creating the client, there is no way to set the client attributes other then calling clientauthconfig.clients6.google.com/v1/clients. BTW, did you tried calling that endpoint ? What authentication is using ?crisp2u
@crisp2u Try with having a single callback endpoint, that endpoint will further redirects (301) to your subdomain callback. basically you can use state (of OAuth2) with auth URL which has information for final redirection URL (sub-domain callback URL).kumar saurav

2 Answers

0
votes

You would need API client to create new API client anyway. Is it really necessary for you to create it this way? You can rather create multiple "user" credentials for your application using only that one API client.

0
votes

I think you are looking for something like this, hope Java is good for you.

I've also found the following relevant information that might help you. Link

Also relevant for you. Link

Let me know.