Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Login with Facebook & Github clients gives following errors:
Message Notice: Undefined index: id_token in Drupal\openid_connect\OpenIDConnect->buildContext() (line 258 of /app/web/modules/contrib/openid_connect/src/OpenIDConnect.php)
TypeError: Argument 1 passed to Drupal\openid_connect\OpenIDConnect::parseToken() must be of the type string, null given, called in /app/web/modules/contrib/openid_connect/src/OpenIDConnect.php on line 258 in Drupal\openid_connect\OpenIDConnect->parseToken() (line 724 of /app/web/modules/contrib/openid_connect/src/OpenIDConnect.php)
Comments
Comment #2
tormiComment #3
tormiSo the problem is that
id_token
doesn't get set for the Facebook / Github client.Comment #4
tormiComment #5
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedI think this is a duplicate of #3216991: Argument 1 passed to OpenIDConnectClientBase::retrieveUserInfo() must be of the type string, array given
Comment #6
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedComment #7
tormiNo, I'm using
2.x
.openid_connect.settings.yml
:Comment #8
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedYes. I know you're using 2.x. Is this still a problem?
Comment #9
tormiUnfortunately yes.
Comment #10
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedWith alpha6 or the dev version?
Comment #11
tormi2.x-dev
Comment #13
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedIndeed. I think I see where the problem was. Can you try now?
Comment #15
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedSome further hardening to prevent PHP warnings about undefined indexes.
Comment #16
tormiThanks! Tried Facebook client and now it gives me the following error:
No "sub" found from facebook
with default settings. Same applies to Github client.Comment #18
tormiYou're the man! Thanks again, João!
Comment #19
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedYes, the problem there was that we started enforcing types in functions a while ago. And the OpenIDConnect::extractSub() function only accepted arrays or nulls. I added a check to see if the first parameter was an array, but forgot the null option. I've now removed that function altogether as it was a single-use function, so it was easier to just move all its 8 lines to the place where that single call occurred.