Django und Google openid Authentifizierung (openid.ax) mit socialauth
-
21-09-2019 - |
Frage
Ich versuche, Django-socialauth zu verwenden ( http://github.com/uswaretech/Django- Socialauth ) für Benutzer für mein django Projekt zu authentifizieren.
Dies ist Tannen Zeit mit openid arbeiten, und ich habe zu Figur hat, wie genau diese offen id funktioniert. Ich habe mehr oder weniger verstand es, jetzt, aber es gibt nur wenige Dinge, die mir entziehen.
Der Authentifizierungsprozess beginnt, wenn die Anforderung in gesetzt wird zusammen in django-socialauth.openid_consumer.views.begin. Ich kann sehen, dass die scheidende Authentifizierungsanforderung mehr oder weniger so etwas wie diese:
https://www.google.com/accounts/o8/ud?openid.assoc_handle=AOQobUckRThPUj3K1byG280Aze-dnfc9Iu6AEYaBwvHE11G0zy8kY8GZ&
openid.ax.if_available=fname&
openid.ax.mode=fetch_request&
openid.ax.required=email&
openid.ax.type.email=http://axschema.org/contact/email&
openid.ax.type.fname=http://example.com/schema/fullname&
openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&
openid.identity=http://specs.openid.net/auth/2.0/identifier_select&
openid.mode=checkid_setup&openid.ns=http://specs.openid.net/auth/2.0&
openid.ns.ax=http://openid.net/srv/ax/1.0&
openid.ns.sreg=http://openid.net/extensions/sreg/1.1&
openid.realm=http://localhost/&
openid.return_to=http://localhost/social/gmail_login/complete/?janrain_nonce=2010-03-20T11%3A19%3A44ZPZCjNc&openid.sreg.optional=postcode,country,nickname,email
Das ist viel wie 2. Beispiel hier: http://code.google.com/apis/accounts/docs/ OpenID.html # -Beispiele
.Das Problem ist, dass die Anforderung, ich komme zurück, ist nichts, wie das entsprechende Beispiel aus code.google.com (Blick auf das dritte Beispiel in Beispiel Antworten Antwort DIKT i bekommen ist wie folgt:
{
'openid.op_endpoint': 'https://www.google.com/accounts/o8/ud',
'openid.sig': 'QWMa4x4ruMUvSCfLwKV6CZRuo0E=',
'openid.ext1.type.email': 'http://axschema.org/contact/email',
'openid.return_to': 'http://localhost/social/gmail_login/complete/?janrain_nonce=2010-03-20T17%3A54%3A06ZHV4cqh',
'janrain_nonce': '2010-03-20T17:54:06ZHV4cqh',
'openid.response_nonce': '2010-03-20T17:54:06ZdC5mMu9M_6O4pw',
'openid.claimed_id': 'https://www.google.com/accounts/o8/id?id=AItOghawkFz0aNzk91vaQWhD-DxRJo6sS09RwM3SE',
'openid.mode': 'id_res',
'openid.ns.ext1': 'http://openid.net/srv/ax/1.0',
'openid.signed': 'op_endpoint,claimed_id,identity,return_to,response_nonce,assoc_handle,ns.ext1,ext1.mode,ext1.type.email,ext1.value.email',
'openid.ext1.value.email': 'my.emailaddress@gmail.com',
'openid.assoc_handle': 'AOQobUfssTJ2IxRlxrIvU4Xg8HHQKKTEuqwGxvwwuPR5rNvag0elGlYL',
'openid.ns': 'http://specs.openid.net/auth/2.0',
'openid.identity': 'https://www.google.com/accounts/o8/id?id=AItOawkghgfhf1FkvaQWhD-DxRJo6sS09RwMKjASE',
'openid.ext1.mode': 'fetch_response'}
Die socialauth selbst gebaut wurde per E-Mail-Adresse auf diese Weise akzeptieren:
elif request.openid and request.openid.ax:
email = request.openid.ax.get('email')
Und natürlich dies nicht gelingt.
Warum ich alle bin frage das, ist, dass ich vielleicht etwas falsch mache und meine ausgehende Anfrage ist falsch? Oder bin ich alles richtig zu tun und sollte das socialaouth Modul ändern Informationen in einer neuen Art und Weise zu übernehmen und dann die Änderung zu begehen?
Alan
Lösung
Versuchen Sie, das vollständige Attribut URI in Ihrem ax.get
verwenden, das heißt ax.get('http://axschema.org/contact/email')