question

VicePhenek-7065 avatar image
1 Vote"
VicePhenek-7065 asked JarvanZhang-MSFT edited

How to use azure B2C with Essentials: Web Authenticator?

Hello,
I am trying to consume B2C user flow authentification with Web Authenticator
(from essentials package Xamarin.forms or MAUI). Web-authenticator

I am unable to add correctly some parameters required for B2C
like 'client_id', 'scope', etc... inside the url, I got always 'bad url' message.

 var url = new Uri("https://{tenant}.b2clogin.com/{tenant}.onmicrosoft.com/{policy}/oauth2/v2.0/authorize?client_id{ClientId}&response_type=code&scope={Scope}");  
 var callbackUrl = new Uri("myapp://auth");  
 var authResult = await WebAuthenticator.AuthenticateAsync(new WebAuthenticatorOptions  
    {  
       Url = url,  
       CallbackUrl = callbackUrl,  
       PrefersEphemeralWebBrowserSession = false,  
    });  

Did someone achieved this kind of stuff?

dotnet-xamarinazure-ad-b2c
· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I am unable to add correctly some parameters required for B2C like 'client_id', 'scope', etc... inside the url, I got always 'bad url' message.

Hi, VicePhenek-7065. The parameters such as 'client_id' and 'scope' should be get in the Azure portal. For example, clicent_id is the application ID assigned to your app in the Azure portal.

For more details, please refer to this doc: https://docs.microsoft.com/en-us/azure/active-directory-b2c/authorization-code-flow#1-get-an-authorization-code

0 Votes 0 ·

Yeah I know thx @JarvanZhang-MSFT
But I was trying to use Web Authenticator and I don't know how to put parameters like 'client_id', 'scope', etc..

We need to add them in to http request like this

 GET https://{tenant}.b2clogin.com/{tenant}.onmicrosoft.com/{policy}/oauth2/v2.0/authorize?client_id={ClientId}&response_type=code&scope={Scope}

But I think Web Authenticator if I do so will add at the end

 ?redirect_uri={callbackUrl}

But the ? character is wrong, tell me if I am wrong





0 Votes 0 ·

Sorry for my mistake. To put the parameter, try using '&' instead. You could search with the keyword as 'easy with Web Authenticator' to refer to the related documentation.

0 Votes 0 ·
Show more comments

Hi, if the posted answer resolves your question, please mark it as the answer by clicking the check mark. Doing so helps others find answers to their questions.

0 Votes 0 ·

It does not.

0 Votes 0 ·

0 Answers