本文介绍了如何使用Python在Azure AD中验证令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!


  1. 我已经在。

  2. 然后我git克隆了并成功运行。

  3. 但是我想请求我的自定义API,所以我替换了资源,但是我弄错了。资源URI类似于 http://< talent-id> / TodoListDaemon

  1. I have registered two apps following this Azure AD demo from step1 to step 4.
  2. And I git cloned Azure AD demo and ran it successfully.
  3. But I want to request my custom API, so I replace the resource,but i get something wrong. The resource URI appears like http://<talent-id>/TodoListDaemon.

现在,我有两个问题:


  1. 如何设置真正的资源?

  2. 自定义api中的额外工作方式


推荐答案

要验证令牌,您可以使用PyJWT和加密技术支持RS256算法。要通过HTTP提取外部信息,可以使用请求。

To validate the token you can use PyJWT and cryptography to support the RS256 algorithm. For fetching external information through HTTP you can use requests.

尝试:

pip install pyjwt cryptography requests

然后使用应用程序ID验证令牌。

Then validate the token using the App ID.

import jwt

app_id = 'd31a4d20-6c4a-1a40-b74d-1a3d461bb3d8'
access_token = 'XXXX'
token_header = jwt.get_unverified_header(access_token)

许多人已经问过这在Stack Overflow上可以参考他们的线程。

A number of others have already asked about this on Stack Overflow and you can refer to their threads. How to verify JWT id_token produced by MS Azure AD?

这篇关于如何使用Python在Azure AD中验证令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 17:36