I am searching for a sample of how azure b2c authentication is integrated into Android. Basically, I need to enable login/signup. There are so many examples but the one I am expecting. Please help me with this.

I tried your sample given in Git repo. And getting Error occurred during authentication

2 Answers

MohitVerma-MSFT On

You can find the simplest and recommended example for Android with Azure ad B2c here

AppAuth for Android is a client SDK for communicating with OAuth 2.0 and OpenID Connect providers. It strives to directly map the requests and responses of those specifications, while following the idiomatic style of the implementation language. In addition to mapping the raw protocol flows, convenience methods are available to assist with common tasks like performing an action with fresh tokens.

The library follows the best practices set out in OAuth 2.0 for Native Apps including using Custom Tabs for the auth request. For this reason, WebView is explicitly not supported due to usability and security reasons.

The library also supports the PKCE extension to OAuth which was created to secure authorization codes in public clients when custom URI scheme redirects are used. The library is friendly to other extensions (standard or otherwise) with the ability to handle additional parameters in all protocol requests and responses.

This sample demonstrates how to use Azure AD B2C using a 3rd party library called AppAuth. It has only been tested for compatibility in basic scenarios with Azure AD B2C. Issues and feature requests should be directed to the library's open-source project.

Hope it helps.

Md Farid Uddin Kiron On

So you would like to authenticate your android application using azure B2C.

To do that follow the below steps:

Register Your Application:

  1. Create your application on azure portal as Native Client
  2. For Android make sure select Allow implicit flow to Yes

See the screen shot below:

enter image description here

You could also check application registration process here

Configure Your Application Id and Application Secret:

Once you have created your application now you have to configure

  1. Published scopes:

See the screen shot:

enter image description here

  1. Keys:

Generate your application Secret Clicking on Key side menu. Then click on Generate key and click Save. See the below screen shot

enter image description here

Android Application configuration:

Download this Android Application and configure Your Application Id which is CLIENT_ID and REDIRECT_URI copy both from your azure portal registered application.

Now follow the instruction to sign in your application.