I setup a Google OAuth Connection following the guide listed here. If I omit the OAuth scopes for this provider I am able to successfully connect, however, for this application, I need the token to be assigned with specific scope privileges and as soon as I add a scope in, (for example https://www.googleapis.com/auth/analytics.readonly) It refuses to connect. I added a debug statement in the source code and found that this seems to be caused by this error:
“array_merge(): Argument #2 must be of type array, string given” /var/www/html/vendor/verbb/auth/src/clients/google/provider/Google.php:75.
Turns out $options['scope'] always returns a string, even if additional scopes are added within the control panel (thus always causing the array_merge error).
Steps to reproduce
Setup a craft 4 build (4.4.15)
Install Consume Plugin
Follow instructions to create a Google OAuth Client here
Add an additional scope
Test connection
Craft CMS version
4.4.15
Plugin version
1.0.3
Multi-site?
No
Additional context
Checking my database, the object settings column contains the object : {"proxyRedirect":"$DEV_MODE","clientId":"$CONSUME_GA_CLIENT_ID","clientSecret":"$CONSUME_GA_SECRET","scopes":["https:\/\/www.googleapis.com\/auth\/analytics.readonly"]}
The web logs contain the object:
'verbb\\consume\\clients\\oauth\\Google' => [ 'clientId' => '$CONSUME_GA_CLIENT_ID' 'clientSecret' => '••••••••••••••••••' 'scopes' => [ 0 => [ 'scope' => 'https://www.googleapis.com/auth/analytics.readonly' ] ] 'proxyRedirect' => '$DEV_MODE' ]
Describe the bug
I setup a Google OAuth Connection following the guide listed here. If I omit the OAuth scopes for this provider I am able to successfully connect, however, for this application, I need the token to be assigned with specific scope privileges and as soon as I add a scope in, (for example https://www.googleapis.com/auth/analytics.readonly) It refuses to connect. I added a debug statement in the source code and found that this seems to be caused by this error:
“array_merge(): Argument #2 must be of type array, string given” /var/www/html/vendor/verbb/auth/src/clients/google/provider/Google.php:75.
Turns out $options['scope'] always returns a string, even if additional scopes are added within the control panel (thus always causing the array_merge error).
Steps to reproduce
Craft CMS version
4.4.15
Plugin version
1.0.3
Multi-site?
No
Additional context
Checking my database, the object settings column contains the object :
{"proxyRedirect":"$DEV_MODE","clientId":"$CONSUME_GA_CLIENT_ID","clientSecret":"$CONSUME_GA_SECRET","scopes":["https:\/\/www.googleapis.com\/auth\/analytics.readonly"]}
The web logs contain the object:
'verbb\\consume\\clients\\oauth\\Google' => [ 'clientId' => '$CONSUME_GA_CLIENT_ID' 'clientSecret' => '••••••••••••••••••' 'scopes' => [ 0 => [ 'scope' => 'https://www.googleapis.com/auth/analytics.readonly' ] ] 'proxyRedirect' => '$DEV_MODE' ]