google-api-php-client icon indicating copy to clipboard operation
google-api-php-client copied to clipboard

user to impersonate get authemtication errors on google my business api

Open jmckay56 opened this issue 10 years ago • 6 comments

Using V.2.0.0 RC6

If I include $user_to_impersonate = '[email protected]'; $client->setSubject($user_to_impersonate);

I can not access the api and get this exceptiion { "error": "unauthorized_client", "error_description": "Unauthorized client or scope in request." } It was working fine until yesterday 9-march around 4 pm pst. If I access without the sub, I can not see my account listings.

Is there a workaround for this?

jmckay56 avatar Mar 10 '16 19:03 jmckay56

Getting the same error with version 1.1.6 and $scopes = ['https://www.googleapis.com/auth/analytics.readonly']; Good to know it's not a version issue at least.

Seems maybe Google updated their API to disallow top level accounts being impersonated, but I haven't seen that documented anywhere online yet.

My Stack Overflow about it here: http://stackoverflow.com/questions/35923375/impersonated-user-unauthorized-in-google-analytics-api-using-service-account

Authorization still works without the $user_to_impersonate, but I need to impersonate our main company account in order to access all our GA accounts.

jqr108 avatar Mar 10 '16 22:03 jqr108

Google probably changed the handling of service accounts and this doesn't work anymore.

btibor91 avatar Mar 11 '16 13:03 btibor91

This was not an issues with the api. but with the google api. Which has been resolved.

jmckay56 avatar Mar 14 '16 16:03 jmckay56

@jmckay56 Thanks dude!

jqr108 avatar Mar 14 '16 18:03 jqr108

Hi I am using Using V.2.0.0 RC6 connecting to the Google My Business API $user_to_impersonate = '[email protected]'; $scopes = ['array_of_scopes'];

    $client = new \Google_Client();
    $client->setSubject($user_to_impersonate);
    $client->setAuthConfig('/path/to/service-account.json');
    $client->setScopes($scopes);

This is working for me.

jmckay56 avatar Mar 16 '16 18:03 jmckay56

@JustinBeckwith this is already closed. What action are you expecting me to take?

jmckay56 avatar Feb 01 '21 18:02 jmckay56