1
votes

I am writing a small program to retrieve and display Google Analytics information. I keep getting a 403 Forbidden error because of insufficient permissions.

I read on other posts that you have to add the email address associated with the client id you are using to access analytics in User Management.

The client id I am using however is associated with an installed application and doesn't have an email address, it only lists a client id, client secret, and redirect Urls as credentials in the developer's console.

How can I allow access for this client id when there is no associated email address listed in the developer's console to grant permissions to on the User Management page in Google Analytics?

1
Are you trying to let someone view your analytics data? - DaImTo

1 Answers

3
votes

Simply follow Google's OAuth 2.0 guide for installed applications.

  1. Create a URL for authorization like you would for a web app. Only set redirect_uri to urn:ietf:wg:oauth:2.0:oob.
  2. Point your user to this URL and let him authorize your app. Then the user will receive a code.
  3. Prompt the user to enter this code in your app and use it to retrieve a refresh token from Google.
  4. Store the refresh token and use it to get a fresh access token whenever you need one.