Can not authorize on iOs with Azure Active Directory V2
Elolawyn opened this issue · comments
Issue
I am having problems with authorizing in iOs with Azure Active Directory V2.
Configuration
Bundle id: com.fake
.
Redirection uri provided by azure: msauth.com.fake://auth
.
Used cocoapods
.
Info.plist
:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.fake</string>
<key>CFBundleURLSchemes</key>
<array>
<string>msauth.com.fake</string>
</array>
</dict>
</array>
AppDelegate.h
:
#import <RCTAppDelegate.h>
#import <Expo/Expo.h>
#import <UIKit/UIKit.h>
#import <React/RCTLinkingManager.h>
#import "RNAppAuthAuthorizationFlowManager.h"
@interface AppDelegate : EXAppDelegateWrapper<RNAppAuthAuthorizationFlowManager>
@property(nonatomic, weak) id<RNAppAuthAuthorizationFlowManagerDelegate> authorizationFlowManagerDelegate;
@end
One doubt I have. react navigation says that #import <React/RCTLinkingManager.h>
is added to AppDelegate.m
not AppDelegate.h
(typo?).
AppDelegate.mm
This file is identical to the example provided in this repository except that mine also contain concurrentRootEnabled
as explained in react native upgrade helper
Login.tsx
const config: AuthConfiguration = {
issuer: 'https://login.microsoftonline.com/id/v2.0',
clientId: 'client-id',
redirectUrl: 'msauth.com.fake://auth',
scopes: ['scope1']
}
try {
const authorizeResult: AuthorizeResult = await authorize(config)
console.log(authorizeResult)
} catch (error) {
console.log(error)
}
linking.ts
export const linking: LinkingOptions<RootStackParamList> = {
prefixes: ['msauth.com.fake://'],
config: {
screens: {
Login: 'auth',
}
}
}
Use case
1.- Enter login screen, press login button, authorize
is called.
2.- Device asks for permission to open link. Safari is opened and microsoft login web page is loaded.
3.- Fill form with email and press button to proceed.
4.- Fill form with password and press button to proceed.
5.- Safari closes and goes back to app.
6.- Both Xcode and metro does not print anything, code after authorize
does not seem to execute. Catch block is not executed.
If I try once more after these steps the following happens:
1.- Enter login screen, press login button, authorize
is called.
2.- Device asks for permission to open link. Safari is opened and microsoft login web page is loaded.
3.- Information is still loaded in navigator cache so web page asks for confirmation to proceed instead of filling the form again. I press the button to proceed.
4.- Safari closes and goes back to app.
5.- Both Xcode and metro does not print anything, code after authorize
does not seem to execute. Catch block is not executed.
Environment
- Your Identity Provider:
Azure Active Directory V2
- Platform that you're experiencing the issue on:
iOS
- Your
react-native
Version:0.71.13
- Your
react-native-app-auth
Version:7.0.0
- Are you using Expo?: Yes but it is Expo configured on React Native project (init as react native, expo added on top later).
I actually found the problem. The /
missing at the end of the redirectUrl
in authorize
call. I leave this issue opened for now in case you might want to clarify documentation on expo maybe or the /
?
I actually found the problem. The
/
missing at the end of theredirectUrl
inauthorize
call. I leave this issue opened for now in case you might want to clarify documentation on expo maybe or the/
?
I'm using react native CLI but got the same error on the latest version of react with Azure AAD V2 and v7.1.0 of react-native-app-auth. I can confirm adding the missing /
fixed the error for me as well, like msauth.io.something.fake://auth/
instead of msauth.io.something.fake://auth
Closing, this is already in our documentation and in the Microsoft documentation.