Search code examples
azureoauth-2.0azure-active-directorytokenazure-ad-b2c

how to Get token from URL?


My ADB2C created login page redirects to SPA after successful authentication and has an access token as URL parameter in the redirect URL. First, I want to extract an access token from a URL. Is this possible? And second, I want to store the extracted access token in localstorage. Is this also possible? Once these two are in place, I would expect the SPA to be able to access the backend API using an access token. thank you.


Solution

  • To get access token from URL make use of Postman.

    • In Postman, Open & switch to Authorization tab
    • Select OAuth 2.0 from the Type dropdown
    • In Grant type dropdown, select Authorization Code
    • In callback Url, enter your redirect Url
    • In Auth Url, enter your Authorize Url
    • In Access toke Url, enter your token Url
    • Enter your client ID and enter scope.
    • click the Get New Access Token button.
    • And this will generate access token.

    For more in detail, please refer these links:

    Obtaining an Access Token from Azure B2C using OAuth2.0 Authorization Code with PKCE in POSTMAN (vmsdurano.com).

    Request Access Token in Postman for Azure AD B2C - Stack Overflow.