0
votes

I am looking for an example that can help me with the following flow:

1) Sign in form in an angularJS client

2) Actual sign in in a .net server (not MVC) where we there is context to the user that signed in in order to call another API ->

3) Call the Blockchain Workbench API with the bearer token that is received from step 2.

I have tried a couple of flows but I never get a valid bearer token that enables me to call the workbench API

For example I have used this: http://blog.pomiager.com/post/using-rest-api-in-azure-workbench-blockchain which signs me in but its MVC and I will like to separate it to a client in angular and a C# server.

This one https://github.com/azure-samples/active-directory-dotnet-webapi-onbehalfof may get closer but its still uses MVP.

Thanks

1

1 Answers

1
votes

For SPA Microsoft recommended to use implicit grand flow for authentication and authorization. You can go for implicit grant flow. Getting token using implicit flow follow the below steps:

Step 1:

Set Your Reply URL on your azure portal. I have login through postman that's why entered postman callback URL. See the screen shot below:

enter image description here

Step 2:

Test On postman for this put your necessary information Like below, Make sure you have selected authentication Type as OAuth 2.0:

enter image description here

Step 3:

In response you will get your token like below:

enter image description here

Final Step:

You can access your resource with this token. see the below example:

enter image description here

For more information you can see here Microsoft guide line https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow

also GitHub example https://github.com/oauthjs/angular-oauth2

For Right authentication protocol for your application you can have a look on this document https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-implicit-grant-flow