2012-06-02 41 views
1

我從https://github.com/omab/django-social-auth獲得django社交身份驗證並按照其說明操作。如何在Django-social-auth中應用google和yahoo OpenID

我使用google oauthyahoo auth但問題是,它不能獲得first name和用戶的lastname,這樣我想用OpenID在數據庫中保存first namelast nameemail,等...但在我無法理解如何實現id的文檔。

我也去了http://openid.net/get-an-openid/也許我可以做一個應用程序,但我找不到如何做到這一點。

我的問題是,我如何在我的django中啓用谷歌和雅虎的OpenID

這是我在我的settings.py做過

AUTHENTICATION_BACKENDS = (
    'userena.backends.UserenaAuthenticationBackend', 
    'guardian.backends.ObjectPermissionBackend', 
    'django.contrib.auth.backends.ModelBackend', 
    'social_auth.backends.facebook.FacebookBackend', 
    'social_auth.backends.twitter.TwitterBackend', 
    'social_auth.backends.google.GoogleOAuthBackend', 
    'social_auth.backends.google.GoogleOAuth2Backend', 
    'social_auth.backends.google.GoogleBackend', 
    'social_auth.backends.yahoo.YahooBackend', 
    'social_auth.backends.OpenIDBackend' 
) 


#facebook 
FACEBOOK_APP_ID    = '45252' 
FACEBOOK_API_SECRET   = '234324' 
FACEBOOK_EXTENDED_PERMISSIONS = ['email'] 
#twitter 
TWITTER_CONSUMER_KEY = '234324' 
TWITTER_CONSUMER_SECRET = '234234' 
TWITTER_EXTENDED_PERMISSIONS = ['email'] 
#google 
#GOOGLE_OAUTH2_CLIENT_ID = 23423#'' 
#GOOGLE_OAUTH2_CLIENT_SECRET = '234324' 
#GOOGLE_APP_ID = '23432' 
#GOOGLE_APP_KEY = '234' 
#GOOGLE_SREG_EXTRA_DATA = ''#[('First name', '...')] 
#GOOGLE_AX_EXTRA_DATA = ''# [('...', '...')] 
#yahoo 
#YAHOO_CONSUMER_KEY = '234342' 
#YAHOO_CONSUMER_SECRET = '234234' 

當我acccess http://127.0.0.1:8000/associate/google/http://127.0.0.1:8000/associate/yahoo/它去雅虎的log.in或谷歌,但它不會登錄我的我的Django項目而當我看到我的數據庫,不創建用戶...

我覺得在使用OpenIDgoogleyahoo並不需要KEYID。所以它不需要app就像我在facebooktwitter中所做的那樣?

我總是在我的日誌得到這個:

Generated checkid_setup request to https://www.google.com/accounts/o8/ud with assocication AMlYA9XiAAnknkW9He8EyJeKuzgFtnhl9YByYurLWutc80ZtG_5XwbOW 
[02/Jun/2012 15:00:23] "GET /associate/google/ HTTP/1.1" 200 2390 
Error attempting to use stored discovery information: <openid.consumer.consumer.TypeURIMismatch: Required type http://specs.openid.net/auth/2.0/signon not found in ['http://specs.openid.net/auth/2.0/server', 'http://openid.net/srv/ax/1.0', 'http://specs.openid.net/extensions/ui/1.0/mode/popup', 'http://specs.openid.net/extensions/ui/1.0/icon', 'http://specs.openid.net/extensions/pape/1.0'] for endpoint <openid.consumer.discover.OpenIDServiceEndpoint server_url='https://www.google.com/accounts/o8/ud' claimed_id=None local_id=None canonicalID=None used_yadis=True >> 
Attempting discovery to verify endpoint 
Performing discovery on https://www.google.com/accounts/o8/id?id=AItOawmyGFHvB71i5EXC9I1dyjOKEXxIPJtHRqM 
Received id_res response from https://www.google.com/accounts/o8/ud using association AMlYA9XiAAnknkW9He8EyJeKuzgFtnhl9YByYurLWutc80ZtG_5XwbOW 
No handlers could be found for logger "SocialAuth" 

也有人能幫助我,我怎麼能在我的Django項目申請OpenIDgoogleyahoo

在此先感謝....

回答

1

我也有一些實施OpenID的問題。 SocialAuth給了我錯誤頁面,沒有任何解釋。

經過一番研究,我發現問題在於管道設置。在我的情況下,我的pipeline.py出錯了。有些方法有錯誤,但Django很安靜,沒有記錄任何錯誤。

錯誤不再出現,當我改變SOCIAL_AUTH_PIPELINE一些簡單的值:

SOCIAL_AUTH_PIPELINE = (
    'social_auth.backends.pipeline.social.social_auth_user', 
    'social_auth.backends.pipeline.associate.associate_by_email', 
    'social_auth.backends.pipeline.misc.save_status_to_session', 
    'social_auth.backends.pipeline.user.get_username', 
    'social_auth.backends.pipeline.user.create_user', 
    'social_auth.backends.pipeline.social.associate_user', 
    'social_auth.backends.pipeline.social.load_extra_data', 
    'social_auth.backends.pipeline.user.update_user_details', 
    'social_auth.backends.pipeline.misc.save_status_to_session', 
) 

此設置是從SocialAuth自述服用。

總之,如果身份驗證不起作用,並且日誌中什麼都沒說,問題可能在流水線中(在設置或方法中)。

相關問題