douzhuang2570 2015-11-23 13:17
浏览 67
已采纳

Google Analytics - 第三方访问帐户授权

I am writing a script in which it queries Google Analytics and with the information it pulls back it creates a report.

I have went through the PHP Quickstart guide on Google Analytics website and got the developer service account set up and working.

However the problem I have run in to is that I can only access the accounts that have this email on and many other accounts I cannot add this to as I don't have permission. We cannot get the developer service account on to these accounts but we do have a company email with read permissions on their accounts.

Is there any way of querying Google Analytics through the company email instead of the developer service account? Or is there some other way of querying Google Analytics to get the information I need from their accounts?

  • 写回答

2条回答 默认 最新

  • doufubu2518 2015-11-23 13:31
    关注

    Service accounts work when you have access to the account in question, or if the owner of the account is willing to grant your service account access to the account in question by adding it as a user.

    If you cant do that then you use Oauth2 and this will require that the owner or a user of the account. Basically anyone with access goes in and authenticates your application. Hello Analytics API: PHP quickstart for web applications is the official documentation for using Oauth2. Since your company email has access to their accounts you should just be able to authenticate the application using that email and then access it.

    If you are trying to automate this. You are going to need to request offline access in order to get a refresh token then save the refresh token you will then be able to access that accounts at anytime to create your reports. without needing to reauthenticate the application.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?