註冊淘寶帳號,關聯實名認證的支付寶帳號,並進行實人認證html
在控制檯-服務發佈中點擊建立新應用python
選擇須要的應用標籤,進行申請,這裏以百川無線應用爲例git
申請時,會讓註冊百川帳號,進行內容遷移github
進入阿里百川,建立應用,app地址最好寫正式的,否則後面還要從新下載web
點擊左側的API申請,選擇剛建立的應用django
點擊個人產品後臺-開通百川電商sdk和雲帳號json
這時返回淘寶開發者平臺-應用管理,就能看到相應信息api
點擊應用管理-設置回調地址bash
http://127.0.0.1:8000/login/taobao-t
已經得到app_key和app_secret
點擊sdk下載,解壓(本項目中採用的是social_django三方登陸庫,不用這一步)
三方設置——阿里百川文檔:https://www.kancloud.cn/moxiuxun/taoke_app/709080
已經建立過網站應用的,在移動應用裏點擊關聯騰訊開放平臺
填寫網站應用的AppID和AppKey
未完,待續
找到自定義用戶模型擴展繼承的AbstractUser類
位置:虛擬環境下\Lib\site-packages\django\contrib\auth\models.py
說明:six.PY3 返回一個表示當前運行環境是否爲python3的boolean值
發現調用了兩個大類:UnicodeUsernameValidator和ASCIIUsernameValidator
進入UnicodeUsernameValidator類
修改定義的規則
regex = r'^[\S.@+-]+$'
微博:https://open.weibo.com/wiki/%E5%BE%AE%E5%8D%9AAPI
(須要審覈才能申請開通調用用戶信息接口-挺麻煩的)
淘寶:http://open.taobao.com/doc.htm?docId=102635&docType=1
百度:http://developer.baidu.com/wiki/index.php?title=docs/oauth
github:https://developer.github.com/v3/oauth_authorizations/
開源中國:https://www.oschina.net/openapi/docs
螞蟻金服:https://openhome.alipay.com/developmentDocument.htm
優酷土豆:https://doc.open.youku.com/?docid=483
eoLinker:[https://www.eolinker.com]( https://s.growingio.com/gNKZYz),必須說的是 eoLinker 開源免費的。
一些產品的開源項目和連接:
開源支持:[https://www.eolinker.com/#/os/download]( https://www.eolinker.com/#/os/download)
Github:[https://github.com/eolinker]( https://github.com/eolinker)
碼雲:[https://gitee.com/eoLinker-API-Management]( https://gitee.com/eoLinker-API-Management)
Coding:[https://coding.net/u/eolinker/project]( https://coding.net/u/eolinker/project)
Blog:[http://blog.eolinker.com]( http://blog.eolinker.com )
視頻教程:[http://blog.eolinker.com/#/course/]( http://blog.eolinker.com/#/course/)
1. 微信硬件設備開發文檔: http://iot.weixin.qq.com/index.html
2. 微信-藍牙開發demo: http://iot.weixin.qq.com/document-4_1.html
3. 申請微信公衆平臺接口測試帳號: http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login
4. 微信公衆平臺開發文檔: http://mp.weixin.qq.com/wiki/home/index.html
5. 微信JS-SDK開發的Demo: http://demo.open.weixin.qq.com/jssdk/
6. 微信JS-SDK開發文檔: http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
# coding:utf-8 """ 注意:登陸可成功,退出時 清除session仍是有殘留信息 Baidu OAuth2 backend, docs at: http://developer.baidu.com/wiki/index.php?title=docs/oauth """ from .oauth import BaseOAuth2 class BaiduOAuth2(BaseOAuth2): """Baidu OAuth authentication backend""" name = 'baidu' ID_KEY = 'uid' AUTHORIZATION_URL = 'http://openapi.baidu.com/oauth/2.0/authorize' ACCESS_TOKEN_URL = 'https://openapi.baidu.com/oauth/2.0/token' ACCESS_TOKEN_METHOD = 'POST' REDIRECT_STATE = False EXTRA_DATA = [ ('userid', 'userid'), ('username', 'username'), ('portrait', 'portrait'), ('sex', 'sex') ] def get_user_details(self, response): """Return user details from Baidu. """ username = response.get('username') return {'username': username, 'first_name': username} def get_uid(self, access_token): """Return uid by access_token""" data = self.get_json( 'https://openapi.baidu.com/rest/2.0/passport/users/getLoggedInUser', method='POST', params={'access_token': access_token} ) return data['uid'] def user_data(self, access_token, *args, **kwargs): uid = self.get_uid(access_token) response = self.get_json( 'https://openapi.baidu.com/rest/2.0/passport/users/getInfo', params={ 'access_token': access_token, } ) response['uid'] = uid return response
baidu.py
# 自定義補充 class TAOBAOAuth2(BaseOAuth2): """Taobao OAuth authentication mechanism""" name = 'taobao' ID_KEY = 'taobao_open_uid' ACCESS_TOKEN_METHOD = 'POST' AUTHORIZATION_URL = 'https://oauth.taobao.com/authorize' ACCESS_TOKEN_URL = 'https://oauth.taobao.com/token' EXTRA_DATA = [ ('taobao_user_id', 'taobao_user_id'), ('taobao_user_nick', 'taobao_user_nick'), ('access_token', 'access_token'), ('token_type', 'token_type') ] def user_data(self, access_token, *args, **kwargs): """Return user data provided""" try: return self.get_json('http://gw.api.taobao.com/router/rest', params={ 'method': 'taobao.user.get', 'fomate': 'json', 'v': '2.0', 'access_token': access_token }) except ValueError: return None def get_user_details(self, response): """Return user details from Taobao account""" fullname, first_name, last_name = self.get_user_names( response.get('name') ) username = response.get('taobao_user_nick') return { 'username': username, 'first_name': first_name, }
taobao.py
說明:
# coding:utf-8 """ Oschina OAuth2 backend, docs at: https://www.oschina.net/openapi/docs """ from .oauth import BaseOAuth2 class OschinaOAuth2(BaseOAuth2): """Oschina OAuth authentication backend""" name = 'oschina' ID_KEY = 'uid' AUTHORIZATION_URL = 'https://www.oschina.net/action/oauth2/authorize' ACCESS_TOKEN_URL = 'https://www.oschina.net/action/openapi/token' ACCESS_TOKEN_METHOD = 'POST' REDIRECT_STATE = False EXTRA_DATA = [ ('name', 'username'), ('portrait', 'portrait'), ('gender', 'gender') ] def get_user_details(self, response): """Return user details from Oschina. """ username = response.get('name') return {'username': username, 'first_name': username} def user_data(self, access_token, response=None, *args, **kwargs): """Return user data""" user_data = self.get_json( 'https://www.oschina.net/action/openapi/my_information', params={'access_token': access_token} ) return user_data
1.Django-1.10支持中文用戶註冊登陸:https://www.cnblogs.com/dribs/p/8376040.html
2.求推薦一個開源的 API 文檔管理系統:https://www.v2ex.com/t/106648
3.bilibili開放平臺相關:https://www.helplib.com/c/mutia_127096