Error refreshing the OAuth2 token { “error” : “invalid_grant” }

隐身守侯 提交于 2019-12-06 02:11:51

I just got my analytics working with a service account yesterday - so I might be able to help. From the console, https://console.developers.google.com/project, you can select your project and go to "APIS & AUTH". Make sure analytics API is turned on. And make sure you have service account "credentials". Make sure to grant the service account email address permissions for your google analytics property. You will also need to get the P12 key file for your service account and provide that key file on your server. I actually use the complete file path for my $key_file_location variable.

I used this code on GitHub: https://github.com/google/google-api-php-client/blob/master/examples/service-account.php

The example is for the Books API - so just replace "Books" with "Analytics" and "books" with "analytics". Fill in your service account credentials and remember to add your service account email to your google analytics property.

You just confirm your service account email id is associated wit google analytics account, and have proper permissions.

The second thing you make sure .P12 file is generated after compiling above step.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!