"error": "unauthorized_client", "error_description": "AADSTS700016 (Microsoft Graph API)
"error": "unauthorized_client", "error_description": "AADSTS700016 (Microsoft Graph API)
我想使用 Microsoft graph API 访问我的待办事项列表,因此注册了一个应用程序并在完成所需的步骤后获得了访问令牌,但在尝试使用刷新令牌获取新的访问令牌后它returns 此消息: "error": "unauthorized_client", "error_description": "AADSTS700016: Application with identifier 'id' was not found in the directory 'Microsoft Accounts'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant
class Refresh:
def __init__(self):
self.refresh_token = refresh_token
self.scope = scope
self.client_secret = client_secret
def refresh(self):
query = "https://login.microsoftonline.com/common/oauth2/v2.0/token"
response = requests.post(query,
data={"client_id" : client_id,
"scope": 'Tasks.Read%20Tasks.Read.Shared%20Tasks.ReadWrite%20Tasks.ReadWrite.Shared%20offline_access',
"refresh_token": refresh_token,
"redirect_uri": 'https://github.com/Rohith-JN',
"grant_type": "refresh_token",
"client_secret": client_secret
},
headers={"Content-Type": "application/x-www-form-urlencoded"})
response_json = response.json()
print(response)
print(response_json)
a = Refresh()
a.refresh()
我也不确定我是否以正确的方式进入范围。任何帮助将不胜感激
我终于通过更改从
刷新令牌的URL弄明白了
https://login.microsoftonline.com/common/oauth2/v2.0/token
到这个https://login.microsoftonline.com/{tenant_id}/oauth2/token
我想使用 Microsoft graph API 访问我的待办事项列表,因此注册了一个应用程序并在完成所需的步骤后获得了访问令牌,但在尝试使用刷新令牌获取新的访问令牌后它returns 此消息: "error": "unauthorized_client", "error_description": "AADSTS700016: Application with identifier 'id' was not found in the directory 'Microsoft Accounts'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant
class Refresh:
def __init__(self):
self.refresh_token = refresh_token
self.scope = scope
self.client_secret = client_secret
def refresh(self):
query = "https://login.microsoftonline.com/common/oauth2/v2.0/token"
response = requests.post(query,
data={"client_id" : client_id,
"scope": 'Tasks.Read%20Tasks.Read.Shared%20Tasks.ReadWrite%20Tasks.ReadWrite.Shared%20offline_access',
"refresh_token": refresh_token,
"redirect_uri": 'https://github.com/Rohith-JN',
"grant_type": "refresh_token",
"client_secret": client_secret
},
headers={"Content-Type": "application/x-www-form-urlencoded"})
response_json = response.json()
print(response)
print(response_json)
a = Refresh()
a.refresh()
我也不确定我是否以正确的方式进入范围。任何帮助将不胜感激
我终于通过更改从
刷新令牌的URL弄明白了https://login.microsoftonline.com/common/oauth2/v2.0/token
到这个https://login.microsoftonline.com/{tenant_id}/oauth2/token