我在Angular JS中的前端。
用户使用gmail登录后会向我发送Google令牌
在后端,我验证令牌并从中提取信息,如下所示
@csrf_exempt
def check(request):
CLIENT_ID = 'xxxxx'
try:
json_data = json.loads(request.body.decode('utf-8'))
idinfo = id_token.verify_oauth2_token(json_data['google_token'], requests.Request(), CLIENT_ID)
if idinfo['iss'] not in ['accounts.google.com', 'https://accounts.google.com']:
raise ValueError('Wrong issuer.')
print("idinfo")
print(idinfo)
现在我在这里获得了用户详细信息,并希望生成一个访问令牌来访问每个请求的API。
oauth2是否有内置函数来生成访问令牌。
任何可以帮助我的建议。感谢。