Hi @Luka
Thank you for posting this in Microsoft Q&A.
I understand that an account was created for you, a B2C Tenant was set up where your account was invited and given administrator privileges, and an App Registration was created for your use. You are obtaining a bearer token and with it, you are attempting to access the https://graph.microsoft.com/v1.0/me endpoint, but you are encountering a "401 Unauthorized" error.
You are utilizing a B2C tenant, and your application is located within this B2C tenant, not in the Microsoft Entra tenant. Therefore, you should use the B2C tenant endpoint instead of the Microsoft Entra endpoint.
Microsoft Entra endpoints to get authorization code and access token: https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow
Get https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?
Post https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
B2C tenant Endpoints to get authorization code and access token: https://learn.microsoft.com/en-us/azure/active-directory-b2c/authorization-code-flow
GET https://{tenant}.b2clogin.com/{tenant}.onmicrosoft.com/{policy}/oauth2/v2.0/authorize?
POST https://{tenant}.b2clogin.com/{tenant}.onmicrosoft.com/{policy}/oauth2/v2.0/token
To retrieve names in a B2C token, there is no necessity to utilize the Graph API endpoint at https://graph.microsoft.com/v1.0/me. Azure AD B2C allows the use of user flows and custom policies to facilitate identity user experiences.
- User flows are predefined, built-in, configurable policies that we provide so you can create sign-up, sign-in, and policy editing experiences in minutes.
- Custom policies enable you to create your own user journeys for complex identity experience scenarios that are not supported by user flows. Azure AD B2C uses custom policies to provide extensibility.
Please follow below steps:
1.Register a web application, create a client certificate, and ensure to grant administrative consent to the permissions. I believe the owner has already created the application in B2C. I would like to request that you cross-check the application against this document
2.Create a sign-up and sign-in user flow and test flow you will get token along with claims.
Please follow the steps outlined in this document.: Create user flows and custom policies in Azure Active Directory B2C
If my understanding of the issue is incorrect, for instance, if your application is hosted within a Microsoft tenant, please let me know, and I will provide assistance.
Hope this helps. Do let us know if you any further queries.
Thanks,
Navya.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.