Services: active-directory-b2c platforms: Android
The MSAL Android preview gives your app the ability to begin using the Microsoft Cloud by supporting Azure B2C using industry standard OAuth2 and OpenID Connect. This sample demonstrates all the normal life cycles your application should experience, including:
- Sign in a user with Local Accounts or Social Identity Providers
- Get an Access Token for a Web Service
- Call the Web Service
- Edit the User's Profile
- Sign out the user
PublicClientApplication pApp = new PublicClientApplication( this.getApplicationContext(), Constants.CLIENT_ID, String.format(Constants.AUTHORITY, Constants.TENANT, Constants.SISU_POLICY)); pApp.acquireToken(getActivity(), scopes, getAuthInteractiveCallback()); // ... authenticationResult.getAccessToken();
Optional: Register you App
The app comes pre-configured for testing. If you would like to register your own app, please follow the steps below.
You will need to have a native client application registered with Microsoft using the Azure Portal. Once done, update your app configs in Constants.Java.
Checkout the sample Web Service code to run it on your own!
Steps to Run
- Clone the code.
git clone https://github.com/Azure-Samples/active-directory-b2c-android-native-msal.git
Open Android Studio 2, and select open an existing Android Studio project. Find the cloned project and open android-client.
Select Build > Clean Project.
Select Run > Run 'app'. Make sure the emulator you're using has Chrome, if it doesn't follow these steps. In Android Studio, we recommend using the Pixel image with Android 24.
- Redirect URI format:
msal<YOUR_CLIENT_ID>://authis strictly enforced by MSAL at the current time.
- For other docs on Azure AD B2C, checkout the B2C dev guide
Community Help and Support
We use Stack Overflow with the community to provide support. We highly recommend you ask your questions on Stack Overflow first and browse existing issues to see if someone has asked your question before.
If you find and bug or have a feature request, please raise the issue on GitHub Issues.
We enthusiastically welcome contributions and feedback. You can clone the repo and start contributing now. Read our Contribution Guide for more information.
This library controls how users sign-in and access services. We recommend you always take the latest version of our library in your app when possible. We use semantic versioning so you can control the risk associated with updating your app. As an example, always downloading the latest minor version number (e.g. x.y.x) ensures you get the latest security and feature enhancements but our API surface remains the same. You can always see the latest version and release notes under the Releases tab of GitHub.
If you find a security issue with our libraries or services please report it to email@example.com with as much detail as possible. Your submission may be eligible for a bounty through the Microsoft Bounty program. Please do not post security issues to GitHub Issues or any other public site. We will contact you shortly upon receiving the information. We encourage you to get notifications of when security incidents occur by visiting this page and subscribing to Security Advisory Alerts.