Microsoft Graph API 身份验证 - 访问令牌为空
Microsoft Graph API Authentication - Access token is empty
我正在尝试获取不记名令牌以将文件上传到 Microsoft Teams。
当向
发出 post 请求时
https://graph.microsoft.com/{tenantId)/oauth2/v2.0/token
body:
client_id,
scope= https://graph.microsoft.com/.default,
grant_type= authorization_code,
client_secret & redirect uri (https://myenvironment.com/callback)
代码:我通过向
发出请求得到了这个
https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize?client_id={client_id}&response_type=code&redirect_uri={redirect_uri}&response_mode=query&scope=https://graph.microsoft.com/.default
我收到 401 Unauthorized 错误代码 InvalidAuthenticationToken
和错误消息 Access token is empty
。
我不确定你想在这里调用哪个 api,但我可以给你举个例子。比如我想打电话给this api帮我上传一个文件
然后我需要给api权限才能调用这个api,你可以在这里看到api权限
然后打开浏览器发送这样的请求
https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/authorize?
client_id=client_id
&response_type=code
&redirect_uri=http%3A%2F%2Flocalhost:8080%2F
&response_mode=query
&scope=Files.ReadWrite Files.ReadWrite.All Sites.ReadWrite.All
&state=12345
然后你会在url中得到一个代码,然后应付这个代码。
Post: https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
request header
Content-Type:application/x-www-form-urlencoded
request body
client_id:
client_secret:
code: copy_from_browser_url
redirect_uri:http://localhost:8080/
grant_type:authorization_code
scope:Files.ReadWrite Files.ReadWrite.All Sites.ReadWrite.All
我正在尝试获取不记名令牌以将文件上传到 Microsoft Teams。 当向
发出 post 请求时https://graph.microsoft.com/{tenantId)/oauth2/v2.0/token
body:
client_id,
scope= https://graph.microsoft.com/.default,
grant_type= authorization_code,
client_secret & redirect uri (https://myenvironment.com/callback)
代码:我通过向
发出请求得到了这个https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize?client_id={client_id}&response_type=code&redirect_uri={redirect_uri}&response_mode=query&scope=https://graph.microsoft.com/.default
我收到 401 Unauthorized 错误代码 InvalidAuthenticationToken
和错误消息 Access token is empty
。
我不确定你想在这里调用哪个 api,但我可以给你举个例子。比如我想打电话给this api帮我上传一个文件
然后我需要给api权限才能调用这个api,你可以在这里看到api权限
然后打开浏览器发送这样的请求
https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/authorize?
client_id=client_id
&response_type=code
&redirect_uri=http%3A%2F%2Flocalhost:8080%2F
&response_mode=query
&scope=Files.ReadWrite Files.ReadWrite.All Sites.ReadWrite.All
&state=12345
然后你会在url中得到一个代码,然后应付这个代码。
Post: https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
request header
Content-Type:application/x-www-form-urlencoded
request body
client_id:
client_secret:
code: copy_from_browser_url
redirect_uri:http://localhost:8080/
grant_type:authorization_code
scope:Files.ReadWrite Files.ReadWrite.All Sites.ReadWrite.All