釘釘掃碼第三方登入

2021-09-30 20:51:43 字數 1317 閱讀 1138

介於公司內部軟體需要做釘釘統一登入。

主要的邏輯流程:

二話不說,上**(由python去實現)

url_tmp_auth_code = ''

def login(request):

body = json.loads(request.body.decode())

#獲取前端傳入的引數dingcode

ding_code = body.get('ding_code')

if not ding_code:

return response(data=}, status=401)

#url_access_token獲取token的url,獲取token

res = requests.get(url_access_token)

data =

headers =

url_tmp_auth_code = url_tmp_auth_code + json.loads(

res.text).get('access_token')

#url_tmp_auth_code釘釘獲取使用者unionid的介面,通過token和dingcode

req = requests.post(url_tmp_auth_code, headers=headers, json=dict(data))

unionid = json.loads(req.text).get('unionid')

print(unionid)

try:

#通過unionid去資料庫中獲取對應的使用者資訊

user = users.objects.get(unionid=unionid)

except:

return response(data=}, status=401)

if user.is_active != 1:

return response(data=}, status=401)

#做登入操作

login(request, user)

print(request.user.unionid)

request.session['is_login'] = true

request.session['fs_ywpt'] = true

request.session.set_expiry(0)

return response(data=})

python後端是有django去實現的,這裡做了登入的介面實現。

第三方登入

我的應用就可以通過token第三方應用獲取一些基本資訊了,我的應用在獲取到這些基本資訊之後,就可以在我的應用中建立乙個賬號了。下次使用地方登入獲取到的這些使用者資訊,就可以直接用來登入我的應用了。為什麼先返回code呢?這個返回的code只能夠使用一次。這個code是從qq的伺服器返回給 時,我們時...

第三方登入

分類 android 2014 03 26 10 24 329人閱讀收藏 舉報 android android開發 第三方登入 名詞說明 access toekn 授權成功後返回的token,用於呼叫第三方api 第三方登入的主要作用 1 使用第三方賬號資訊來初始化自己的賬號 暱稱 頭像等資訊 第三...

React專案中第三方使用微信掃碼登入

首先,還是在index.html檔案中引入js doctype html en utf 8 name viewport content width device width,initial scale 1,shrink to fit no theme color content 000000 man...