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.
I made quick, dirty hack of OpenID module to add Google Federated Login. In current state, user can use https://www.google.com/accounts/o8/id as OpenID URL, but Google does not provide any username or e-mail to use for user account creation. Several parameters in OpenID request are needed to get e-mail address.
$request['openid.ns.ext1'] = "http://openid.net/srv/ax/1.0";
$request['openid.ext1.mode'] = 'fetch_request';
$request['openid.ext1.type.email'] = 'http://schema.openid.net/contact/email';
$request['openid.ext1.required'] = 'email';
Then username is derived from e-mail address.
if ($response['openid.ext1.value.email'] != '' and $response['openid.op_endpoint'] == 'https://www.google.com/accounts/o8/ud') {
$response['openid.sreg.email'] = $response['openid.ext1.value.email'];
$response['openid.sreg.nickname'] = substr($response['openid.ext1.value.email'], 0, strpos($response['openid.ext1.value.email'], '@'));
}
And I also added possibility to use Google account e-mail as OpenID URL (AFAIK Google is the only provider to use this, but in future, some others may tend to it, so that code should definitely be changed to something better)
if(strpos($claimed_id, '@') > 1) {
$xrds_url = 'https://www.google.com/accounts/o8/id';
}
Comment | File | Size | Author |
---|---|---|---|
#19 | 339600-19_google_openid_6.patch | 2.25 KB | alex_b |
#5 | glogin.zip | 6.05 KB | etaroza |
openidgoogle.patch | 1.66 KB | Christof | |
Comments
Comment #1
Christof CreditAttribution: Christof commentedComment #2
deshilachado CreditAttribution: deshilachado commentedWould be nice if someone could review and accept this patch, because currently GMail accounts cannot be used as OpenID (or at least I could not figure out how to use it - just getting "Sorry, that is not a valid OpenID." error message).
Comment #3
Dries CreditAttribution: Dries commentedI was actually hopeful that Google would "fix" their OpenID implementation. Let's sit back and wait a couple more weeks before we include this in Drupal 7.
Comment #5
etaroza CreditAttribution: etaroza commentedFor me the patch wasn't enough, so I created a module based on the openid module (with some copy-paste as well). For personal purposes I also removed the openid login links with (you may want to do the same if you only want Google):
In case people find it useful, I will be more than happy to create a separate project for this module. For now I simply attach it. (See README.txt for some notes).
Comment #6
Dave ReidComment #7
jasperwiet CreditAttribution: jasperwiet commentedCan I make this glogin module also work under drupal 5.x? (I have no programming skills unfortunately)
Thanks everyone for the efforts by the way!
Comment #8
deshilachado CreditAttribution: deshilachado commentedthe google federated login is some form of "google special" openID
before drupal 6 openID support was a module which you can find here:
http://drupal.org/project/openid
since D6 this module was integrated into drupal core.
so i think for D5 support you have better chances on the project page
(if you decide to file an issue there you could link to this issue here;
see below for instructions how to link to an issue number)
Comment #9
nikemen CreditAttribution: nikemen commentedCan I do that on D6?
Comment #10
moshe weitzman CreditAttribution: moshe weitzman commentedHas google "fixed" their openid?
Comment #11
Heine CreditAttribution: Heine commentedWe fixed our OpenID implementation to deal with OP Identifiers.
#216101: OpenID fails to auto-register account: Username invalid, email required handles situations where OpenID providers do not pass a name or emailaddress.
Whatever we do, I'd like to avoid any special coding for particular OpenID providers.
Comment #12
Vacilando CreditAttribution: Vacilando commentedSubscribing to this thread.
Btw, Google is recently trying to make the public used to the idea of federated login / hybrid onboarding. This article today made me search, yet again, for a way how to register / authenticate users in Drupal 6 using Google Account.
Comment #13
mikl CreditAttribution: mikl commentedIt seems that Google has not "fixed" their OpenID implementation, and I consider it highly unlikely that they will make any changes of the sort needed to make it work with the current Drupal OpenID module, since that would likely break compatibility with the current implementation.
So either we should go out and say we do not support authentication via Google's Federated Login or apply a patch like the aforementioned to fix the issue.
Comment #14
Heine CreditAttribution: Heine commentedAs we modified our OpenID implementation to support OP Identifiers, and #216101: OpenID fails to auto-register account: Username invalid, email required deals with the remaining issue, marking this duplicate.
Comment #15
Anonym CreditAttribution: Anonym commentedopenidgoogle.patch queued for re-testing.
Comment #16
Damien Tournoud CreditAttribution: Damien Tournoud commentedNothing is required here anymore.
Comment #17
LenInkster-1 CreditAttribution: LenInkster-1 commentedopenidgoogle.patch queued for re-testing.
Comment #19
alex_b CreditAttribution: alex_b commented#11 Heine: I hear you. But adding a fallback maybe just enough - see attached patch. I whipped that up in 6 because I need it to work for a project at hand. I can roll a D7 patch if we like this approach.
Comment #20
andriy_gerasika CreditAttribution: andriy_gerasika commentedsee a patch at http://drupal.org/node/946998#comment-3628378 -- it introduces attribute exchange to Drupal 6 core OpenID module. Code is backported from Drupal 7.
Comment #22
c960657 CreditAttribution: c960657 commentedSupporting AX is covered by #634562: OpenID AX support. This issue has been fixed in D7 and should be backported.
The Google OpenID Provider does not provide a nickname field, so the user has to choose one himself. In [##216101: OpenID fails to auto-register account: Username invalid, email required we decided against trying to make up one based on the users email. Instead the information text is updated to reflect this. This has been fixed in both D7 and D6.
Comment #23
euractiv CreditAttribution: euractiv commented#19: 339600-19_google_openid_6.patch queued for re-testing.
Comment #25
Anonym CreditAttribution: Anonym commentedComment #26
mgiffordI don't think this is getting into Core. Certainly not D6 or D7 Core.