xamarin - How to integrate the new AD B2C and the C# Azure Mobile Client lib? -


i have secured api app , have tested adb2c flow sample app found here: https://github.com/azure-samples/active-directory-b2c-xamarin-native. using structure, can trigger sign-in process, , access protected api calls.

however wanted use windowsazure.mobile sdk convenience. hinted @ here: https://cgillum.tech/2016/08/10/app-service-auth-and-azure-ad-b2c-part-2/ can trigger b2c flow loginasync in class nothing when call in way.

i found https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-dotnet-how-to-use-client-library/ (scroll "authenticate users active directory authentication library") substituted msal calls getting token. triggers sign-on flow, token , claims back, put in json , pass so:

authenticationresult ar = await app.pcapplication.acquiretokensilentasync(app.scopes, "", app.authority, app.signupsigninpolicy, false); jobject payload = new jobject(); payload["access_token"] = ar.accesstoken; user = await app.mobileservice.loginasync( mobileserviceauthenticationprovider.windowsazureactivedirectory, payload); 

this call loginasync throws

{microsoft.windowsazure.mobileservices.mobileserviceinvalidoperationexception: not have permission view directory or page. @ microsoft.windowsazure.mobileservices.mobileservicehttpclient+<throwinvalidresponse>d__18.movenext () [0x0022f] in <filename unknown>:0 --- end of stack trace previous location exception thrown --- (snip)

are not designed work together? different kinds of tokens? reason i'm using b2c because don't want know oauth stuff :)

in case of b2c, getting id token instead of access token, , believe ar.accesstoken property null. property seems go away in latest versions of msal.

i suspect need update payload "authenticationtoken" , instead use ar.idtoken.

i not sure if can continue use "access_token" key in payload, may can. if not, try "authenticationtoken" instead.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -