【发布时间】:2021-01-18 22:40:47
【问题描述】:
我有一个角度 UI,当用户使用 google 登录并通过标头发送生成的访问令牌时,它会进行 API 调用。 API 调用部分如下所示:
this.http.get(
`${environment.nodeURL}/api/myApiCall`,
{ headers: { authorization: this.accessToken}
})
API 是使用 flask-Python3 制作的。我想将该访问令牌存储在 API 中的局部变量中。 谁能建议我如何获得价值?我尝试通过以下方式获取值:
@api.route('/verify_token')
@api.response(404, 'Invalid access_token')
class UserCheck(Resource):
def get(self):
""" Checks if the access token is valid or not """
response = urllib.request.urlopen('http://localhost:5000/user/verify_token')
print("Header value is...............",response.getheader('access_token'))
我目前在 localhost 中运行 UI 和 API。
【问题讨论】: