Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Add ability to request OpenID attributes such as email_address #25

podiobooks opened this Issue · 11 comments

6 participants


Hello! I'm working with your library, and the basics seem to be working smoothly!

However, I'd really prefer to request that the OpenID provider pass on the customer's basic data at least, like this (inserted into get_redirect, in

from openid.extensions import sreg
sreg_request = sreg.SRegRequest(required=['nickname'], optional=['fullname', 'email'])

Ideally, a config param set:





does this works? do you know how to do the same with facebook?


For the above code to work, I added something like this on /socialregistration/

if client.is_valid():
    from openid.extensions import sreg
    resp = sreg.SRegResponse.fromSuccessResponse(client.result)
    if resp:
        print '==> nickname', resp.get('nickname', '')
        print '==> fullname', resp.get('fullname', '')
        print '==> email', resp.get('email', '')
        print '==> No OpenID->Simple Regisration support!'

Note: I'm still looking how to do that on my own app, not on django-socialregistration itself.

Please note that not all OpenID-capable sites support Simple Registration as explained here:

To get same from Facebook? Try the following on your :

graph = request.facebook.graph 
fb_profile = graph.get_object("me")
first_name = fb_profile['first_name']
last_name = fb_profile['last_name']

For reference, look here


thanks that was very useful, espacially for facebook, it works great.
For openid, i finally don't like the sreg method since it doesn't work with google.
socialregistration working with django-openid doesn't support Attribute Exchange AX i suppose?


vallettea, so to retrieve facebook user's name and e-mail what do I have to do?


sorry for the delay francis,
to get email and user's name from facebook, I had to modifiy the code of the views of social_registration (dirty i know) adding
graph = request.facebook.graph
fb_profile = graph.get_object("me")
first_name = fb_profile['first_name']
last_name = fb_profile['last_name']
email = fb_profile['email']

in the facebook_login function


Hi, thank you very much.
I was able to get the first and last name, but the email is an unknown key, as there isn't any. How did you get the email permissions?


they are asked by the popup window that asks the user if he accepts to sign in and give his infos


+1 This would be extremely useful.


this exchange helps with facebook but it seems there is still no solution to retreive the email from google. Does anyone has some new hints about the subject?


in in OpenID(object)

    URLS = {
      'ax_email': '',
      'ax_first': '',
      'ax_last': '',

def get_redirect(self):
    auth_request = self.consumer.begin(self.endpoint)
    ax_request = ax.FetchRequest()
    ax_request.add(ax.AttrInfo(URLS['ax_email'], required = True))
    ax_request.add(ax.AttrInfo(URLS['ax_first'], required = True))
    ax_request.add(ax.AttrInfo(URLS['ax_last'], required = True))

and in in def openid_callback(...)

if client.is_valid():
    identity = client.result.identity_url

    email = first_name = last_name = None
    ax_response = ax.FetchResponse.fromSuccessResponse(client.result)

    email = ax_response.getSingle('', email)
    first_name = ax_response.getSingle('', first_name)
    last_name = ax_response.getSingle('', last_name)

also import in both files
from openid.extensions import ax

and that's that.


Guys, has there been any movement on this topic? Im really keep to use socialreg for a large company but the need to specify required user info is paramount? I'd appreciate any news you could provide :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.