Search code examples
azurecomputer-visionocr

Authorize Azure Requests using Bearer toke?


Is it possible to send a request to Microsoft Azure OCR using authorization token instead of Subscription-Key? I searched a lot on the internet but found nothing and thus I would be thankful If you can help.


Solution

  • Basically, you can follow this workflow:

    1. users send a request to your App for an access token.
    2. Your app checks the user's permission(you should implement the procedure yourself), if vailed, your app uses a subscription key to get an access token for the user by Authenticate with Azure Active Directory and reply this token to the user.
    3. Users use this token to call the OCR service from client-side.

    As the doc indicated, you should create a new service principal in your Azure AD, and go to Azure Portal=>your Azure cognitive service => Access control to add a cognitive service user role to the new created SP:

    enter image description here

    So that it could request an access token for this service from Azure AD by request below:

    enter image description here

    By using this access token, we will be able to call vision ocr service:

    enter image description here

    Endpoint in this case:

    enter image description here