12

This is more an Azure B2C question than a flutter/android question:

TLDR: How can I get a B2C JWT token 'eyJhbGciO...' with a Google access token 'ya29.Glss...'?

We are building an app with flutter that uses Azure B2C to manage the users. While this works fine with simple_auth, we are not huge fans of the whole 'browser popup navigation'/chrome custom tab and we would love to use the native google sign in plugin that shows the local google accounts and allows us to get an access and id token from google (the tokens start with 'ya29.Glss...'. But what are we supposed to do with these two tokens afterwards? I assume I'll have to post it to some custom policy/endpoint somewhere on B2C to receive a B2C token (starting with 'eyJhbGciO...') or do I need to request the token from google with some other parameters?

Any help would be appreciated. Cheers

Chief Wiggum
  • 2,784
  • 2
  • 31
  • 44

2 Answers2

3

You can create a resource owner password credential (ROPC) flow that enables a native app to collect a user credential and exchange it for an ID token, an access token, and a refresh token with the Azure AD B2C tenant.

These Android and iOS samples demonstrate how you can integrate an Android or iOS app and the ROPC flow using the AppAuth SDKs.

Chris Padgett
  • 14,186
  • 1
  • 15
  • 28
  • I'm aware of the ROPC flow, but I want the native Google Account Picker to work with B2C instead of the standard flow in the browser. ROPC doesn't allow me to pick from a list of google accounts (or facebook etc) and then log into B2C, or am I mistaken? – Chief Wiggum Jul 03 '19 at 08:24
  • 1
    Hi @ChiefWiggum. Google Sign-In allows apps to sign users in using their Google accounts and then access services on behalf of these Google users. To this end, Google Sign-In can't be used with Azure AD B2C. However, you might consider implementing a similar experience for Azure AD B2C using a native app with AppAuth or MSAL. – Chris Padgett Jul 04 '19 at 02:52
2

It seems the scenario you are trying might not work with B2C or any other Identity products, You can try the below link to integrate B2C in android with opensource package.

https://azure.microsoft.com/en-in/resources/samples/active-directory-b2c-android-native-appauth/

MA0608
  • 324
  • 1
  • 4
  • I'm awarding you the points since there were no other answers.It uses a browser tab and this is exactly what I'm not looking for. I'm looking for a solution involving the native google account selector. Anyway, thanks for your effort. – Chief Wiggum Jul 01 '19 at 07:56
  • @ChiefWiggum did you find a solution to this? – gllambi Jun 22 '22 at 03:27
  • @gllambi Unfortunately not. We've switched to Firebase Auth since the whole integration was much better back. I don't know how it's today though. – Chief Wiggum Jun 22 '22 at 04:46