Bearer Token w/ C# REST API

Julio Caproni 31 Reputation points
2022-08-18T01:19:43.46+00:00

Hi guys,

I am quite confusing/lost with somethings that I was requested to do. It is basically, Bearer Token authentication with my users stored on Azure Storage Account, I spent basically two days looking how can I do that, but I could find nothing on internet, I'm beginner into this coding life, I might have misunderstood some explanations, whenever I click to read there are some many pages of everything that, its quite hard to get it.

I'm looking for some kind of guiding through this, because I don't know from where I should start.

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,826 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,291 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,497 questions
{count} votes

2 answers

Sort by: Most helpful
  1. CowieCowie 76 Reputation points
    2022-08-18T02:57:20.513+00:00

    Hi 95289493, its suggested to use SAS authentication rather than bearer token to get to Azure Storage Account. Therere huge amounts of official tutorials about it.
    You can find how you build a sample and get blob or something else from your Azure Storage Account (with REST API) from the link below:
    Link1. storage-rest-api-auth
    232160-1.png

    I also found something that might be helpful for you.

    Link2. C# REST API tutorials: console-webapiclient
    Link3. Authentication and Bearer token tutorials: authentication-and-authorization

    If you are still confused about your problem, please comment here and we can discuss more about it. If my answer were useful, please accept it and kindly up vote it!
    Dont be afraid of coding, its normal to feel confused from time to time at the beginning of coding. Happy coding!


  2. SaiKishor-MSFT 17,216 Reputation points
    2022-08-19T18:12:28.867+00:00

    @Julio Caproni Thank you for reaching out to Microsoft Q&A. I understand that you want to know how you can achieve Bearer Token that can be used for authentication.

    Here are some articles which talk about getting the Bearer Token- https://documenter.getpostman.com/view/6227162/T1Ds8abg

    https://www.linkedin.com/learning/azure-for-developers-introduction-to-the-microsoft-identity-platform/solution-obtain-a-bearer-token?autoplay=true&resume=false&u=0

    As seen, if you use POSTMAN, it has the script already to get this token once you populate the Tennant ID, Client ID and Client secret. Here is how to get these three values by creating a service principal- https://learn.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli, which will result in an output which includes all these values as shown below-

    232956-create-sp.png

    Where, AppID- Client ID
    Password- Client password
    Tenant- Tenant ID

    Hope this helps. Please let us know if you have any further questions/concerns and I will be glad to assist further. Thank you!

    0 comments No comments