rmcfarlane82 / react-native-msal-plugin Goto Github PK
View Code? Open in Web Editor NEWReact Native Plugin that wraps Microsoft MSAL library allowing you to authenticate with azure B2C
License: MIT License
React Native Plugin that wraps Microsoft MSAL library allowing you to authenticate with azure B2C
License: MIT License
Hello. Seems that library doesn't provide ability to sign out user. So, i've called method "tokenCacheDelete", but when i open login window next time i see that User still Signed in and doesn't ask password for login. Is there a way to logout user except of clicking "Sign out" inside browser?
First i created a project then i added cocoapod with latest version 0.4.3 then i run two commands
npm install react-native-msal-plugin
react-native link react-native-msal-plugin
i got error
'MSAL/MSAL.h' file not found
Hi there,
I have an issue.
When I call authClient.acquireTokenAsync()
, it shown the bellow error on iOS
TypeError: Cannot read property 'acquireTokenAsync' of undefined
at MsalPlugin.acquireTokenAsync (MsalPlugin.js:22)
at loginWithMicrosoft$ (Login.js:67)
at tryCatch (runtime.js:45)
at Generator.invoke [as _invoke] (runtime.js:271)
at Generator.prototype.<computed> [as next] (runtime.js:97)
at tryCatch (runtime.js:45)
at invoke (runtime.js:135)
at runtime.js:170
at tryCallTwo (core.js:45)
at doResolve (core.js:200)
Could you tell me how to fix please?
Thanks in advance.
"react-native": "0.59.8",
"react-native-msal-plugin": "^3.0.0"
Platform: iOS
I'm just opening this issue to make it easy for other people to find.
This plugin will not work on iOS 13 because it is using an old version of the obj-c MSAL library which does not work on iOS 13.
[ts] Property 'SELECT_ACCOUNT' does not exist on type 'typeof MsalPlugin'. [2339]
occurs on line 150 on the B2CLoginExample.tsx. I think something's wrong with the import/exports.
This looks great, but do you have a simple working version example that doesn't use typescript?
Sorry, I'm a noob with react native.
"we are discontinuing efforts in the Auth, Data, and Push services and working to retire these preview services in App Center. "
https://devblogs.microsoft.com/appcenter/app-center-mbaas-retirement/
When using standard authority string (e.g. https://login.microsoftonline.com/tfp/{COMPANY}.onmicrosoft.com or https://{COMPANY}.b2clogin.com/tfp/{COMPANY}.onmicrosoft.com) works fine for aquireTokenB2CAsync however it fails for methods acquireTokenSilentAsync and tokenCacheB2CDeleteItem with error "Invalid B2C authority".
It lloks like internal Java error in com.microsoft.identity.client.B2cAuthority.updateAuthority() where number of URI segments are expected to be equal to com.microsoft.identity.client.B2cAuthority.B2C_AUTHORITY_SEGMENTS_SIZE = 3. (https://github.com/AzureAD/microsoft-authentication-library-for-android/blob/v0.1.3/msal/src/authority/java/com/microsoft/identity/client/B2cAuthority.java)
But if I pass authority + "/policy" (e.g. https://login.microsoftonline.com/tfp/{COMPANY}.onmicrosoft.com/b2c_1_susi) they both work fine.
Is it the initial purpose of having authority parameter in these methods?
And if I replace authority in the constructor with "augmented" one, then resetPasswordAsync behaves incorrectly and redirects to login.
Why can't all methods use authority that was passed into constructor + add IPolicies to the constructor, so each method will just grab a policy for itself and build a proper authority URI for com.microsoft.identity.client.B2cAuthority?
The iOS MSAL pod's current version is 0.4.3
, and has breaking changes, so this plugin will not work with it without some changes.
Cheers,
Joshua
I am using plugin it is working fine, if i want to do login with different user in microsoft page it is showing previous user. So is there any api available to forget user and logout
I updated to Xcode 11.1 after that i am trying to run msal authentication in simulator. From token async i am getting this error
Illegal callback invocation from native module. This callback type only permits a single invocation from native code.
RCTFatal
checkCallbackMultipleInvocations(bool*)
__41-[RCTModuleMethod processMethodSignature]_block_invoke_2.129
__123-[RNMsalPlugin authority:clientId:scopes:extraQueryParams:loginHint:msalUIBehavior:extraScopesToConsent:resolver:rejecter:]_block_invoke
__177-[MSALPublicClientApplication acquireTokenForScopes:extraScopesToConsent:account:loginHint:uiBehavior:extraQueryParameters:claims:authority:correlationId:apiId:completionBlock:]_block_invoke
__177-[MSALPublicClientApplication acquireTokenForScopes:extraScopesToConsent:account:loginHint:uiBehavior:extraQueryParameters:claims:authority:correlationId:apiId:completionBlock:]_block_invoke.167
__30-[MSALInteractiveRequest run:]_block_invoke_2
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_callback_4CF
CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
UIApplicationMain
main
start
0x0
I'm logging in with Azure AD B2C, and SCOPES is not defined in Azure dashboard. (The Azure app is installed by our customer, and they don't need to setup App ID URI. So there is no scopes set.)
But authClient.aquireTokenB2CAsync
cause error if I don't pass SCOPE parameter, so I pass scope as ["email"]
.
const AUTHORITY = "https://xxx.b2clogin.com/tfp/xxx.onmicrosoft.com";
const CLIENTID = "xxxx";
const SCOPES = ['email'];
const POLICIES = {
signUpSignInPolicy: 'B2C_1_SignUp',
passwordResetPolicy: 'B2C_1_edit_profile',
}
const authClient = new MsalPlugin(AUTHORITY, CLIENTID);
const result = await authClient.aquireTokenB2CAsync(SCOPES, POLICIES, { loginHint: email });
This code is working with version 1.0.2.
But with latest version I'm getting following error:
Error: Error Domain=MSALErrorDomain Code=-42500 "(null)" UserInfo={MSALErrorDescriptionKey=Authentication response received without expected accessToken}
The package name of this plugin 'com.reactlibrary' that specify in AndroidManifest.xml is conflict with another plugin when I tried to export the release apk.
Please change the package name to other name. Maybe com.rmcfarlane should be ok.
I am trying to integrate this plugin in both android and iOS. In iOS it is working fine but in android i am facing this NO certificates found issue
This app Browser has requested a certificate.Choosing a certificate will let the app identify.....
Actually i am checking changing password feature. I changed my password in azure directory, After that i tried silent token it is providing token. But it should throw some error like authentication failed. Is it expected behaviour?
Hello All,
I am able to call the Azure AD MSAL end point, but Redirect URI is having some issues. Not sure from where the Redirect URI is coming from 'msal111111111111://auth'
App.tsx:120 Error: Error Domain=MSALErrorDomain Code=-42003 "(null)" UserInfo={MSALErrorDescriptionKey=AADSTS500112: The reply address 'msal111111111111://auth' does not match the reply address 'msal111111111111://xxx.apps.testapp1' provided when requesting Authorization code.
Trace ID: xxxxxxxx
Correlation ID: f75a53f97997897889
Timestamp: 2019-06-27 01:33:13Z, MSALOAuthErrorKey=invalid_client}
at createErrorFromErrorData (NativeModules.js:155)
at NativeModules.js:104
at MessageQueue.__invokeCallback (MessageQueue.js:414)
at MessageQueue.js:127
at MessageQueue.__guard (MessageQueue.js:314)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:126)
at debuggerWorker.js:80
Thanks in advance
Ashwin
I just taken ios sample example and try to run it , not working
i added cocoapod and try to run it i am getting this error]
React missing #import "React/RCTBridgeModule.h" and all react libraries missing
Hello,
we use this plugin and react-native-image-picker (https://github.com/react-native-community/react-native-image-picker).
But when we call ImagePicker.launchImageLibrary function of react-native-image-picker, app crashes and there is mention of RNMsalPlugin in the crash log:
--------- beginning of crash
2019-03-11 16:00:14.182 24851-24851/com.springshot.SpringshotMobile E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.springshot.SpringshotMobile, PID: 24851
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=13002, result=-1, data=Intent { dat=content://com.google.android.apps.photos.contentprovider/-1/1/content://media/external/images/media/156/ORIGINAL/NONE/159831847 flg=0x1 clip={text/uri-list U:content://com.google.android.apps.photos.contentprovider/-1/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F156/ORIGINAL/NONE/159831847} }} to activity {com.springshot.SpringshotMobile/com.springshot.SpringshotMobile.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.microsoft.identity.client.PublicClientApplication.handleInteractiveRequestRedirect(int, int, android.content.Intent)' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:4268)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4312)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1644)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.microsoft.identity.client.PublicClientApplication.handleInteractiveRequestRedirect(int, int, android.content.Intent)' on a null object reference
at com.reactlibrary.RNMsalPlugin.onActivityResult(RNMsalPlugin.java:43)
at com.facebook.react.bridge.ReactContext.onActivityResult(ReactContext.java:253)
at com.facebook.react.ReactInstanceManager.onActivityResult(ReactInstanceManager.java:692)
at com.facebook.react.ReactActivityDelegate.onActivityResult(ReactActivityDelegate.java:129)
at com.facebook.react.ReactActivity.onActivityResult(ReactActivity.java:75)
at android.app.Activity.dispatchActivityResult(Activity.java:7266)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4264)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4312)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1644)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
2019-03-11 16:00:14.185 24851-24851/com.springshot.SpringshotMobile E/com.marianhello.logging.UncaughtExceptionLogger: FATAL EXCEPTION: mainjava.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=13002, result=-1, data=Intent { dat=content://com.google.android.apps.photos.contentprovider/-1/1/content://media/external/images/media/156/ORIGINAL/NONE/159831847 flg=0x1 clip={text/uri-list U:content://com.google.android.apps.photos.contentprovider/-1/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F156/ORIGINAL/NONE/159831847} }} to activity {com.springshot.SpringshotMobile/com.springshot.SpringshotMobile.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.microsoft.identity.client.PublicClientApplication.handleInteractiveRequestRedirect(int, int, android.content.Intent)' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:4268)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4312)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1644)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.microsoft.identity.client.PublicClientApplication.handleInteractiveRequestRedirect(int, int, android.content.Intent)' on a null object reference
at com.reactlibrary.RNMsalPlugin.onActivityResult(RNMsalPlugin.java:43)
at com.facebook.react.bridge.ReactContext.onActivityResult(ReactContext.java:253)
at com.facebook.react.ReactInstanceManager.onActivityResult(ReactInstanceManager.java:692)
at com.facebook.react.ReactActivityDelegate.onActivityResult(ReactActivityDelegate.java:129)
at com.facebook.react.ReactActivity.onActivityResult(ReactActivity.java:75)
at android.app.Activity.dispatchActivityResult(Activity.java:7266)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4264)
... 9 common frames omitted
I also tried to use another image picker library, but still has similar crash report relating with react-native-msal library.
I am able to run this plugin successfully but randomly i am getting this error
Error: Error Domain=MSALErrorDomain Code=-42100 "(null)" UserInfo={MSALErrorDescriptionKey=User interaction is required, MSALOAuthErrorKey=invalid_grant, MSALOAuthSubErrorKey=basic_action, NSUnderlyingError=0x600000b94a20 {Error Domain=MSALErrorDomain Code=-42004 "(null)" UserInfo={MSALErrorDescriptionKey=AADST435345423: Due to a configuration change made by your administrator, or because you moved to a new location, you must enroll in multi-factor
Return value is defined as IAuthenticationResult but it is Promise
Im now getting the following error
[Error: Intent filter for: BrowserTabActivity is missing. Please refer to the MSAL readme.]
It seems to suggest this issue
AzureAD/microsoft-authentication-library-for-android#479
Is there somewhere other than the AndroidManifest.xml file I need to add the app id to?
I tried to do set login_hint as follow:
const extraQueryParameters = '[email protected]';
await authClient.aquireTokenB2CAsync(AzureConfig.SCOPES, AzureConfig.POLICIES, extraQueryParameters)
But it adds login_hint in url like following:
https://...&%22login_hint=partnertest2018%40outlook.com%22
And it's not adding email field correctly.
How can I set login_hint using extraQueryParameters for aquireTokenB2CAsync function?
i am getting "Error: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference."
In browser my login screen is getting displayed but when i login i am not getting any authentication token back.
I use this library in debug mode. it's good.
But when I tried to export release apk file.
I always got the 'Task :app:transformDexArchiveWithDexMergerForRelease FAILED' error.
After I remove implementation project(':react-native-msal-plugin') . The error disappear.
I tried to add implementation project(':react-native-msal-plugin') again. The error comeback.
Is anyone face this problem?
the MsalClient switches the authority depending on the policy used to sign in, the policy can be retrieved from the id token, the value is stored in the tfp.
Right now, I see an option to add BrowserTabActivity using which the page is navigated to browser for the login page, and through the browser we enter user credentials to sign in. Navigating to browser and entering credentials seem to be a bad experience.
Is there a way to sign in (in app) without navigating to browser? It'll be great if you could help here.
Im trying to use the Common login in a project but am getting the following error
{ [TypeError: undefined is not an object (evaluating 'RNMsalPlugin.acquireTokenAsync')]
on line 22 of MsalPlugin.js
I feel like I am doing something obvious wrong. Any thoughts?
What is the default redirect URI? Also, how to set redirect URI?
Why isn't it using client secret as parameter?
Getting error like after success login: Error: An IO error occurred with message: unexpected end of stream on com.android.okhttp.Address@b7850b38
I am getting below error while running the example
srh:example sham.rh$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
What went wrong:
Could not determine java version from '12'.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
When building an Android app with Android Studio >3.3.0 and Android Gradle Plugin >3.3.0, the following warning occurs:
WARNING: The specified Android SDK Build Tools version (27.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.3.2.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '27.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Remove Build Tools version and sync project
Affected Modules: react-native-msal-plugin
Maybe you could consider updating the build.gradle to something like this (taken from react-native-svg):
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
buildscript {
repositories {
google()
jcenter()
}
dependencies {
//noinspection GradleDependency
classpath rootProject.ext.has('gradleBuildTools') ? rootProject.ext.get('gradleBuildTools') : 'com.android.tools.build:gradle:3.3.0'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion safeExtGet('compileSdkVersion', 28)
//noinspection GradleDependency
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
//noinspection OldTargetApi
targetSdkVersion safeExtGet('targetSdkVersion', 27)
}
lintOptions {
abortOnError false
}
}
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+'
}
Need support for
pod 'MSAL', :git => 'https://github.com/AzureAD/microsoft-authentication-library-for-objc', :tag => '0.2.0'
Because the example from Microsoft repo is based on v0.2.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.