GET 换档偏好问题
GET Shift Preference Issue
获取此 API (https://docs.microsoft.com/en-us/graph/api/shiftpreferences-get?view=graph-rest-1.0&tabs=http)
时出错
请求header:
{'Authorization': 'Bearer eyJ**6MA', 'Content-Type': 'application/json', 'MS-APP-ACTS-AS': '53**76'}
错误响应:{'error': {'code': 'Forbidden', 'message': '{"error":{"code":"Forbidden","message":"The user identifier in the path does not match the one in the authorization token.","details":[],"innererror":{"code":"InvalidOAuthToken"}}}', 'innerError': {'date': '2020-10-06T13:53:08', 'request-id': '093**ad', 'client-request-id': '09**bad'}}}
而且我拥有执行此操作所需的所有权限。
知道这是为什么吗?
我可以很容易地重现你的问题。
如果您使用错误user_id或您使用的令牌不是用户颁发的,就会出现此错误。你可以使用https://jwt.ms/解析你的access token,查看oid Claims,这是你的user_id也是Token issuer,你需要保证和您的请求路径中的 user_id。
还有一个比较简单的方法,直接用Graph Explorer请求这个API(这个需要登录)
获取此 API (https://docs.microsoft.com/en-us/graph/api/shiftpreferences-get?view=graph-rest-1.0&tabs=http)
时出错请求header:
{'Authorization': 'Bearer eyJ**6MA', 'Content-Type': 'application/json', 'MS-APP-ACTS-AS': '53**76'}
错误响应:{'error': {'code': 'Forbidden', 'message': '{"error":{"code":"Forbidden","message":"The user identifier in the path does not match the one in the authorization token.","details":[],"innererror":{"code":"InvalidOAuthToken"}}}', 'innerError': {'date': '2020-10-06T13:53:08', 'request-id': '093**ad', 'client-request-id': '09**bad'}}}
而且我拥有执行此操作所需的所有权限。
知道这是为什么吗?
我可以很容易地重现你的问题。
如果您使用错误user_id或您使用的令牌不是用户颁发的,就会出现此错误。你可以使用https://jwt.ms/解析你的access token,查看oid Claims,这是你的user_id也是Token issuer,你需要保证和您的请求路径中的 user_id。
还有一个比较简单的方法,直接用Graph Explorer请求这个API(这个需要登录)