Coder Social home page Coder Social logo

Comments (13)

vmurin avatar vmurin commented on July 24, 2024

Hi Alex,

the only reason that I can imagine is the wrong callback URI in the app registration. On iOS the SFSafariViewController is used to login. After successful login the "browser" window closes and should call registered callback URI. If there is no according registered URI found in the OS, then the window just closes and nothing happens.
So we have two places where the callback is registered:

  1. Azure portal app registration
  2. The CFBundleURLSchemes key in the Info.plist - see README
    This two must be absolutely identical and contain NO any variables (with $ sign)

Please check this.

from react-native-azure-auth.

alexstoyanov avatar alexstoyanov commented on July 24, 2024

@vmurin Correct me if I am wrong - so if I have package name(Android) and Bundle ID(iOS) = com.example.app
The redirect URIs will be:
iOS -> com.example.app://com.example.app/ios/callback
Android -> com.example.app://com.example.app/android/callback

And the
CFBundleURLSchemes should be:
<key>CFBundleURLSchemes</key> <array> <string>com.example.app</string> </array>

EDIT: The section in README about redirect URIs is a little bit confusing. The iOS URI has variables as {} and ${}...
{YOUR_BUNDLE_IDENTIFIER}://${YOUR_BUNDLE_IDENTIFIER}/ios/callback

Android only {}. I am not sure what should be replaced ...
{YOUR_APP_PACKAGE_NAME}://{YOUR_APP_PACKAGE_NAME}/android/callback

from react-native-azure-auth.

vmurin avatar vmurin commented on July 24, 2024
  1. All is correct. Do not forget to register both (Android and iOS) URIs in Azure

  2. with the $ it was just a typo.
    But as you followed the note 1

Make sure to replace {YOUR_BUNDLE_IDENTIFIER} and {YOUR_APP_PACKAGE_NAME} with the actual values for your application.

you are safe ;)

from react-native-azure-auth.

alexstoyanov avatar alexstoyanov commented on July 24, 2024

@vmurin OK, so I double checked all the data and it is the correct one. The strange thing is that even if I click cancel on the screen of the attachment the app is closed as on the GIF I attached earlier

Screenshot 2019-11-05 at 15 09 58

from react-native-azure-auth.

alexstoyanov avatar alexstoyanov commented on July 24, 2024

@vmurin Also I checked the Info.plist in the example project to compare it to mine and it is missing the <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleTypeRole</key> <string>None</string> <key>CFBundleURLName</key> <string>AzureAuth</string> <key>CFBundleURLSchemes</key> <array> <string>com.my-domain.native-app</string> </array> </dict> </array>
part

from react-native-azure-auth.

vmurin avatar vmurin commented on July 24, 2024

OK. The next point that it could be is your company policy in Azure.
If in the OS the URL scheme registered correctly (we have checked this) then the reason could be, that the callback URL is not called on successful login.
I don't have any enterprise account, only private, so I can't help you and name exactly settings to check. Try to browse through and look what could be suspicious.

And can you check the behavior on Android emulator to compare?

from react-native-azure-auth.

alexstoyanov avatar alexstoyanov commented on July 24, 2024

It is working on Android emulator. I tried to run it on iOS device and now I have a crash report:

Last Exception Backtrace:
0 CoreFoundation 0x1b7e0498c __exceptionPreprocess + 220 (NSException.m:199)
1 libobjc.A.dylib 0x1b7b2d0a4 objc_exception_throw + 56 (objc-exception.mm:565)
2 CoreFoundation 0x1b7d06d1c +[NSException raise:format:arguments:] + 96 (NSException.m:146)
3 Foundation 0x1b813c8f4 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 128 (NSException.m:231)
4 UIKitCore 0x1bbe1a0f8 __58-[UIApplication _applicationOpenURLAction:payload:origin:]_block_invoke + 1136 (UIApplication.m:7111)
5 UIKitCore 0x1bbe19b24 -[UIApplication applicationOpenURLAction:payload:origin:] + 684 (UIApplication.m:7157)
6 SafariServices 0x1c7a905f0 -[SFSafariViewController remoteViewController:hostApplicationOpenURL:] + 568 (SFSafariViewController.m:586)
7 SafariServices 0x1c7a6eb94 -[SFBrowserRemoteViewController willOpenURLInHostApplication:] + 76 (SFBrowserRemoteViewController.m:159)
8 CoreFoundation 0x1b7e0ad90 invoking
+ 144
9 CoreFoundation 0x1b7cdabd0 -[NSInvocation invoke] + 300 (NSForwarding.m:3142)
10 libdispatch.dylib 0x1b7ad2184 _dispatch_client_callout + 16 (object.m:495)
11 libdispatch.dylib 0x1b7a7b038 _dispatch_block_invoke_direct$VARIANT$mp + 224 (queue.c:463)
12 FrontBoardServices 0x1bcee7540 FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 40 (FBSSerialQueue.m:173)
13 FrontBoardServices 0x1bcee720c -[FBSSerialQueue _queue_performNextIfPossible] + 404 (FBSSerialQueue.m:216)
14 FrontBoardServices 0x1bcee7734 -[FBSSerialQueue _performNextFromRunLoopSource] + 28 (FBSSerialQueue.m:247)
15 CoreFoundation 0x1b7d827e0 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 24 (CFRunLoop.c:1922)
16 CoreFoundation 0x1b7d82738 __CFRunLoopDoSource0 + 80 (CFRunLoop.c:1956)
17 CoreFoundation 0x1b7d81ed0 __CFRunLoopDoSources0 + 180 (CFRunLoop.c:1992)
18 CoreFoundation 0x1b7d7d01c __CFRunLoopRun + 1080 (CFRunLoop.c:2882)
19 CoreFoundation 0x1b7d7c8bc CFRunLoopRunSpecific + 464 (CFRunLoop.c:3192)
20 GraphicsServices 0x1c1be8328 GSEventRunModal + 104 (GSEvent.c:2246)
21 UIKitCore 0x1bbe126d4 UIApplicationMain + 1936 (UIApplication.m:4753)
22 Shkolo 0x100823a60 main + 88 (main.m:16)
23 libdyld.dylib 0x1b7c07460 start + 4

Any idea?

from react-native-azure-auth.

alexstoyanov avatar alexstoyanov commented on July 24, 2024

@vmurin Also what about Info.plist I saw that in the example project you don't have CFBundleURLTypes CFBundleTypeRole None CFBundleURLName AzureAuth CFBundleURLSchemes com.my-domain.native-app

from react-native-azure-auth.

vmurin avatar vmurin commented on July 24, 2024

OK. The crash is good ;) it's something that explains the behavior.

About sample app project - I did not ran/tested it on the iOS, only Android. So the iOS part is not maintained properly.

Back to the crash:

  1. Did you checked the URL scheme on allowed characters? See README
  2. I don't have a Mac, but you can check some similar issues and try solutions proposed there.
    Some random issue examples that I came across:

from react-native-azure-auth.

vmurin avatar vmurin commented on July 24, 2024

Stale issue closed due to inactivity

from react-native-azure-auth.

bibekgurunguh avatar bibekgurunguh commented on July 24, 2024

This issue happened to me too on ios both on attempt to log in and when cancelling just like the OP. However, I did get error message which indicated the problem was Linking.removeEventListener('url', urlHandler) line where the error read undefined is not a function.
Commenting that line out seems to have worked. @vmurin do you know why this line is causing the issue and can it be fixed in your library in the next version?

from react-native-azure-auth.

Nohac avatar Nohac commented on July 24, 2024

I'm getting the same exact error as @bibekgurunguh, looking at the the following code:

const urlHandler = (event) => {
NativeModules.AzureAuth.hide()
Linking.removeEventListener('url', urlHandler)
resolve(event.url)
}

I'ts trying to reference urlHandler inside of itself, I don't think that would work 🤔

from react-native-azure-auth.

vmurin avatar vmurin commented on July 24, 2024

Should be fixed in v1.8.5

from react-native-azure-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.