Coder Social home page Coder Social logo

Error. We're having trouble signing you in. Please sign in again. Unauthorized about active-directory-b2c-dotnet-webapp-and-webapi HOT 11 CLOSED

azure-samples avatar azure-samples commented on May 27, 2024
Error. We're having trouble signing you in. Please sign in again. Unauthorized

from active-directory-b2c-dotnet-webapp-and-webapi.

Comments (11)

dblaszyk avatar dblaszyk commented on May 27, 2024 2

Please note, I saw this when I forgot the trailing /, for the api:ApiIdentifier.

.. key="api:ApiIdentifier" value="https://forexample.onmicrosoft.com/myapi"

Must be
.. key="api:ApiIdentifier" value="https://forexample.onmicrosoft.com/myapi/"

Since the scopes are created by appending the security token, I was getting myapiread, as opposed to myapi/read in the code example.

from active-directory-b2c-dotnet-webapp-and-webapi.

parakhj avatar parakhj commented on May 27, 2024

Not sure what message you are seeing. Could you repaste it?

Yes, you will need to make changes to your TaskService Web Config. You need to update it with your B2C configuration (e.g. the client ID of the Web API app registration, your tenant name)

from active-directory-b2c-dotnet-webapp-and-webapi.

MrCharli3 avatar MrCharli3 commented on May 27, 2024

@parakhj The Error-message I get is in the title :) Or did you mean something else?
Okay, but in the walktrough where you link to this GitHub project there is nothing about modifying the TaskService Web Config? Or did I miss it?

from active-directory-b2c-dotnet-webapp-and-webapi.

parakhj avatar parakhj commented on May 27, 2024

There are multiple pages linking to this repo, depending on what you are trying to achieve. Check out the readme of this repo

from active-directory-b2c-dotnet-webapp-and-webapi.

saraford avatar saraford commented on May 27, 2024

@MrCharli3 Hello! 👋 I just made some updates to the readme earlier today that show step-by-step how to register both apps (the web app and the web api) in the Azure portal and how to configure both VS projects (i.e. the sample apps available in the solution in this repo) to use your tenant.

Please take a look and let us know if you still have any questions! Thanks!

from active-directory-b2c-dotnet-webapp-and-webapi.

saraford avatar saraford commented on May 27, 2024

@dblaszyk Thanks for calling this out! I've added a quick 📝 in the readme to verify that the trailing / has been added to the ApiIdentifier.

from active-directory-b2c-dotnet-webapp-and-webapi.

Muddasarr avatar Muddasarr commented on May 27, 2024

I followed all the instructions but when i try to access the to-do-list it gives this error
Error. We're having trouble signing you in. Please sign in again. Unauthorized
Although i am already signed in. Kindly see the attached code below:

<configuration>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0"/>
    <add key="webpages:Enabled" value="false"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
    <add key="ida:Tenant" value="kardexlcs.onmicrosoft.com"/>
    <add key="ida:ClientId" value="5d4bede7-8874-4e2d-8628-aeb62fb102a7"/>
    <add key="ida:ClientSecret" value="-removed-"/>
    <add key="ida:AadInstance" value="https://login.microsoftonline.com/tfp/{0}/{1}/v2.0/.well-known/openid-configuration"/>
    <add key="ida:RedirectUri" value="https://localhost:44316/"/>
    <add key="ida:SignUpSignInPolicyId" value="B2C_1_SiupIN"/>
    <add key="ida:EditProfilePolicyId" value="B2C_1_Sipe"/>
    <add key="ida:ResetPasswordPolicyId" value="B2C_1_SSPR"/>
    <add key="api:TaskServiceUrl" value="https://localhost:44332/"/>
    <!-- Uncomment the localhost url if you want to run the API locally -->
    <!--add key="api:TaskServiceUrl" value="https://localhost:44332/" /-->
    <!-- The following settings is used for requesting access tokens -->
    <add key="api:ApiIdentifier" value="https://kardexlcs.onmicrosoft.com/tasks/"/>
    <add key="api:ReadScope" value="Hello.read"/>
    <add key="api:WriteScope" value="Hello.write"/>
  </appSettings>

Am i missing something in the configuration??
Any help would be highly appreciated.
Thanks in advance.

from active-directory-b2c-dotnet-webapp-and-webapi.

TiagoBrenck avatar TiagoBrenck commented on May 27, 2024

Please, re-open if this is happening in the latest version of this sample

from active-directory-b2c-dotnet-webapp-and-webapi.

LeGnours avatar LeGnours commented on May 27, 2024

Hello,

It seems I am also having the same issue with the lastest documentation.
I've followed the tutorial (https://docs.microsoft.com/en-ca/azure/active-directory-b2c/tutorial-web-api-dotnet?tabs=app-reg-preview) and when I am trying to access the ToDoList, I have :
"We're having trouble signing you in.
Please sign in again. Unauthorized"

After some investigation, it seems that var accounts = await cca.GetAccountAsync(); returns 0 account the first time, it's called. After that, it goes to:
==> return new RedirectResult("/Account/SignUpSignIn?redirectUrl=/Tasks");

Then, it goes again in the Index method and this time there is one account and the UserName is "

It seems that in the TaskController.cs, when I am trying to get the token (even if I am already signin), I get a null AccessToken.

from active-directory-b2c-dotnet-webapp-and-webapi.

AlpeshValvi123 avatar AlpeshValvi123 commented on May 27, 2024

I have followed the same documentation. https://docs.microsoft.com/en-ca/azure/active-directory-b2c/tutorial-web-api-dotnet?tabs=app-reg-ga

I'm successfully login into WebApp.

But getting the issue while accessing the API.
Error.
We're having trouble signing you in.
Please sign in again. Unauthorized

Also, I have granted both web app and well as API from Azure AD B2C.

Any help would be highly appreciated.
Thanks in advance.

from active-directory-b2c-dotnet-webapp-and-webapi.

dbman86 avatar dbman86 commented on May 27, 2024

I had same issue - I went to the WebApp app registration and needed to grant admin consent - before I did the status said something else and was not green. otherwise put a breakpoint in TasksController.Index() when it calls cca.AcquireTokenSilent - does result.AccessToken have a value? it was null for me until I made the change below. hope this helps.

image

from active-directory-b2c-dotnet-webapp-and-webapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.