Problem/Motivation

I wanted to update a My Business Integration from the deprecated Google My Business API v4.9 to the new Business Information API v1. Unfortunately the google/apiclient-services cannot be updated to a version that contains the MyBusinessBusinessInformation service.

Steps to reproduce

Install v4 of the module and add new Google API client. There is no option for the My Business Business Information service.

Proposed resolution

Bump the version of the dependency of google/apiclient-services to the latest version (0.213.0) if possible.

CommentFileSizeAuthor
#8 3284822-6.patch1.43 KBsadashiv

Comments

rezo_rehn created an issue. See original summary.

heyyo’s picture

I opened similar issue here, but more general:
https://www.drupal.org/project/google_api_client/issues/3263031

sadashiv’s picture

Status: Active » Needs review

Have relased 4.2 which installs the latest version of the lib thus the MyBusinessBusinessInformation should show up.

buerorezo’s picture

Status: Needs review » Needs work

Thank 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.

sadashiv’s picture

Status: Needs work » Closed (works as designed)

Google 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.

buerorezo’s picture

Hi 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

sadashiv’s picture

Status: Closed (works as designed) » Needs review

Hi @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

function hook_google_api_client_account_scopes_alter(&$scopes, $google_api_client_id) {
  if ($google_api_client_id == 1) {
    $scopes[] = 'MY_SCOPE';
  }
}

Thanks,
Sadashiv.

sadashiv’s picture

StatusFileSize
new1.43 KB

Forgot attaching patch.

buerorezo’s picture

Many thanks. The patch from #8 is working for me.

sadashiv’s picture

Status: Needs review » Patch (to be ported)

Thanks for the update, will commit this patch in the next version.

Thanks,
Sadashiv.

sadashiv’s picture

Status: Patch (to be ported) » Fixed

Pushing this in new release

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.