1. 钉钉部分
 链接: https://open-doc.dingtalk.com/microapp/serverapi2/kymkv6

2.login页面



    
    Title



3. django view视图 def login(request):     """登录验证"""     if request.method == "GET":         ##########二维码认证登录#############         code = request.GET.get('code', )         appId = 'xxxxxxx'         appSecret = 'xxxxxxxx'         token = requests.get(             'https://oapi.dingtalk.com/sns/gettoken?appid={appId}&appsecret={appSecret}'.format(appId=appId,                                                                                                 appSecret=appSecret))         access_token = token.json()["access_token"]         tmp_auth_code = requests.post(             "https://oapi.dingtalk.com/sns/get_persistent_code?access_token={access_token}".format(                 access_token=access_token),             json={                 "tmp_auth_code": code             })         tmp_code = tmp_auth_code.json()         print(tmp_code)         openid = tmp_code['openid']         persistent_code = tmp_code['persistent_code']         sns_token_request = requests.post(             "https://oapi.dingtalk.com/sns/get_sns_token?access_token={access_token}".format(access_token=access_token),             json={                 "openid": openid,                 "persistent_code": persistent_code             })         sns_token = sns_token_request.json()['sns_token']         user_info_request = requests.get(             'https://oapi.dingtalk.com/sns/getuserinfo?sns_token={sns_token}'.format(sns_token=sns_token))         user_info = user_info_request.json()['user_info']         unionid = user_info.get('unionid')         user_obj = UserInfo.objects.filter(unionid=unionid).first()         request.session['username'] = user_obj.username  # 登录成功后,用户登录信息存>放于session         request.session.set_expiry(86400)  # 设置登录过期时间         content = {'code': 0,                    'msg': 'success',                    'user_info': {                        'user_id': user_obj.id,                        'username': user_obj.username,                        'user_iphone': user_obj.phone,                        'user_email': user_obj.email,                        'user': user_obj.user,                        'D_user': user_obj.D_user                    }                    }         ####################################         content = {'code': 0, 'msg':'success',}         return JsonResponse(data=content,status=status.HTTP_200_OK)