Closed (fixed)
Project:
Google API PHP Client
Version:
8.x-4.0
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
21 Sep 2021 at 11:02 UTC
Updated:
31 Jul 2026 at 15:20 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
heyyo commentedI opened similar issue here, but more general:
https://www.drupal.org/project/google_api_client/issues/3263031
Comment #3
sadashiv commentedHave relased 4.2 which installs the latest version of the lib thus the MyBusinessBusinessInformation should show up.
Comment #4
buerorezo commentedThank you for updating the library. The MyBusinessBusinessInformation now shows up when creating a Google API client entity. But the scopes field stays empty and so the client cannot be saved.
Comment #5
sadashiv commentedGoogle api client module pics all constants of the class and show them as scopes. I checked https://github.com/googleapis/google-api-php-client-services/blob/main/s... and they have not added any scopes, a similar case for other api was reported at https://www.drupal.org/project/google_api_client/issues/3219666 and in that case we tried reaching out to the library maintainers to add the scope and they clarified further.
An alternate way to add scope to the account is to save the account without scopes and then use hook_google_api_client_account_scopes_alter to add scopes.
Feel free to reopen the case if you find that the library has the constant now and the module is not showing it.
Thanks,
Sadashiv.
Comment #6
buerorezo commentedHi Sadashiv,
thanks for your reply and the clarification. I opened an issue for the my business client services requesting to add the needed constants via the discovery doc.
In the meantime i tried to use hook_google_api_client_account_scopes_alter as you proposed. Unfortunately i cannot save a client without chosen scope as the field is required. When saving it with another scope and try to change it via hook_google_api_client_account_scopes_alter it stays with the initial scope in the api client listing and in the database (google_api_client__scopes and google_api_client__services table).
Can you please give me a hint how to set the scopes with hook_google_api_client_account_scopes_alter?
Many thanks in advance,
Tobi
Comment #7
sadashiv commentedHi @buerorezo,
Can you check the attached patch to save the account without any scope and then use the hook_google_api_client_account_scope_alter to add the desired scope.
This hook is invoked only before invoking authenticate so you won't see the scope in the db and other places but you can see it when you authenticate.
You can write code like
Thanks,
Sadashiv.
Comment #8
sadashiv commentedForgot attaching patch.
Comment #9
buerorezo commentedMany thanks. The patch from #8 is working for me.
Comment #10
sadashiv commentedThanks for the update, will commit this patch in the next version.
Thanks,
Sadashiv.
Comment #12
sadashiv commentedPushing this in new release