none
Why is the token returned by ADAL token showing unauthorised on a request made by Postman and how do i resolve it? RRS feed

  • Question

  • I want to make API calls to the Azure Blockchain Workbench from my python app. For that the API calls need a Authorisation bearer. When I get the bearer from the Azure UI Webapp using Inspect Element, the same token bearer works fine with the API calls. However, the bearer returned by ADAL in Python when used in the API call shows 401 unauthorised.

    For the Inspect Element part, I get my token by logging in to https://votemaadi-4bm4ew.azurewebsites.net and then using inspect element.

    In the python part, here is my code

    import adal
    import swagger_client
    from swagger_client.api_client import ApiClient
    context = adal.AuthenticationContext("https://login.microsoftonline.com/kumarshobhit98outlook.onmicrosoft.com/",api_version=None)
    client_id="c62087b9-cfed-4105-a9c2-4fd3953ceed5"
    res='c80344c2-d7fc-41e1-adcc-dd33683a7f6b'
    token = context.acquire_token_with_username_password(resource='https://graph.windows.net',username="shobhit@kumarshobhit98outlook.onmicrosoft.com",password="pass",client_id=client_id)
    print(token['accessToken'])

    I would like to get an authentication bearer in python that i can further use with the API calls

    Friday, August 9, 2019 1:44 PM

Answers

  • Posting the response you got from StackOverflow for future reference:

    token = context.acquire_token_with_username_password(resource=client_id,username="shobhit@kumarshobhit98outlook.onmicrosoft.com",password="pass",client_id=client_id)

    source link: https://stackoverflow.com/a/57454898/5420074

    Wednesday, August 14, 2019 7:19 PM
    Moderator