Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • Is there an API so I can programmatically set this up for my user?
  • If that's not possible, is there a more user-friendly way to obtain Analytics reporting that is future-proof? (I noticed they are currently deprecating a few older APIs)
like image 319
Peter Avatar asked Jun 23 '26 23:06

Peter


1 Answers

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.

like image 125
Jan Gerlinger Avatar answered Jun 25 '26 21:06

Jan Gerlinger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!