POSTMAN: “You do not have permission to view this directory or page” with Bearer Token

前端 未结 2 2109

I\'ve got a website hosted on HostGator, let\'s say it\'s domain is https://example.com.

I also have an application hosted on Azure, with Active Direc

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-16 00:43

    The evilSnobu have already explained this issue which caused by incorrect audience. I want to explain it more general to help understand this issue.

    There are two concepts client and resource server in the OAuth 2.0 Authorization Framework(refer rfc6749). When the client calls the resource server, the resource server will verify the token passed in the request. For example, it will verify the signature, issuer, client id, audience etc.

    client: An application making protected resource requests on behalf of the resource owner and with its authorization. The term "client" does not imply any particular implementation characteristics (e.g., whether the application executes on a server, a desktop, or other devices).

    resource server: The server hosting the protected resources, capable of accepting and responding to protected resource requests using access tokens.

    In your scenario, you were acquire the access_token for the Azure AD Graph(https://graph.windows.net). However, the audience you config at the portal doesn't match the aud claim in the access_token. To fix the issue, we can use the app registered at Azure AD as both client and resource. If that, we need to acquire the access token using the Application ID instead of App ID URI. And config this value as the ALLOWED TOKEN AUDIENCES on the Azure portal.

    Or we can just to register two apps in Azure AD to represent the client app and resource app separately. And using the client app to acquire the token for the resource app. If this, the value of resource should the App ID URI of resource app and we also need to config it as the ALLOWED TOKEN AUDIENCES on the Azure portal.

提交回复
热议问题