Peter
Peter

Reputation: 940

How to programmatically obtain OAuth2 client credentials for Google API

I'm trying to create a redistributable web application that will integrate with Google Analytics through the Google Reporting API. Customer will install the application on their server.

I'm following this tutorial (I'm using PHP, but I believe this is not of importance for my question)

https://developers.google.com/analytics/resources/tutorials/hello-analytics-api

This works fine. No issues there.

However I can't figure out one missing element: The tutorial starts with sending me to the Google APIs console where I have to create and configure a new API project and create and configure a client ID.

That's a lot of work that requires fairly technical knowledge (redirect url, selecting correct API, error-prone copy-and-pasting, etc.)

So my questions:

Upvotes: 3

Views: 2529

Answers (1)

Jan Gerlinger
Jan Gerlinger

Reputation: 7415

Unfortunately that's AFAIK not possible.

You could go one of the following ways:

  • Move client_id and client_secret to some configuration file and help your customer with deployment.

  • Show a one-time setup wizard for your app and guide your customer step-by-step. There you can at least provide him with the right callback URLs.

  • Regard your application as "installed application" and instrument curl or something similar for sending the requests.

Upvotes: 1

Related Questions