question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error 3 on iOS from showUrl when trying to do login in some conditions

See original GitHub issue

Describe the problem

Authorize call doesn’t prompt for login when it should on iOS hardware. With changes in #381 I see the following error occuring from the iOS native code:

LOG {"error": "The operation couldn’t be completed. (com.apple.AuthenticationServices.WebAuthenticationSession error 3.)", "error_code": 3}

It doesn’t seem to happen on initial login. It is happening when I am trying to migrate our app to a new version where we added a couple of new scopes to the request. I have been able to reproduce by deleting the app from my phone and starting over (which results in a successful login) that only breaks when I attempt to add scopes.

What was the expected behavior?

Prompted for login via auth0

Reproduction

Here is the call to authorize:

.authorize({
        audience: 'https://foo.bar.com/api',
        scope: 'offline_access openid email profile',
    }, 
    { ephemeralSession: true })
  1. Log in with a given set of scopes.
  2. Close the running app.
  3. Change the code to add a new scope and rebuild.
  4. Run again and attempt to login

Environment

  • Version of this library used: 2.8.3
  • Which framework are you using, if applicable: React Native 0.64.1, iOS 14.4.2
  • Other modules/plugins/libraries that might be involved:
  • Any other relevant information you think would be useful: Unable to reproduce on the iOS simulator, only on device.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ghillscommented, Jun 2, 2021

That seems like an ASWebAuthenticationSession error, particularly The UIWindowScene for the returned window was not in the foreground active state. (error code 3). By any chance, is this an app that hasn’t been updated (or tested on an iOS device) for a long time? Because that error is related to some iOS 13 changes. And,per chance, are you invoking WebAuth on viewDidLoad?

It’s not an overly outdated app - I have made recent changes to it over the last year that have been tested on device.

However, your second question I think may be on to something with it being timing related. This is happening from react native so it isn’t in viewDidLoad itself but I think in this case we were having UI changes happen at the same time as the login was initiated (Auth0 was actually being called from an async process outside of the component lifecycle).

To confirm this I tried adding an intentional delay before calling authorize and that seems to alleviate the error which leads me to believe it has to do with views changing on the screen when the login was initiated.

Assuming my understanding is correct I will head down that path of restructuring that workflow to make sure the views are not changing at the time of the call to authorize.

Thanks for your help!

0reactions
Widcketcommented, Jun 2, 2021

Glad you were able to start pinpointing the issue. Will close this, please ping if you’d like to reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The operation couldn't be complete… | Apple Developer Forums
The operation couldn't be completed. Unable to log in with account 'myappleid'. An unexpected failure occurred while logging in (Underlying error code 1100)....
Read more >
How to Fix iOS 16 Update Stuck on Terms and ... - YouTube
iOS 16 update stuck at Terms and Conditions, Cannot agree the ... Create Account Your Account Cannot Be Created at this time iOS...
Read more >
Troubleshooting iOS/iPadOS device enrollment errors in ...
Suggestions for troubleshooting some of the most common enrollment and sync token errors when enrolling iOS/iPadOS devices in Intune.
Read more >
There Was an Error Connecting to the Apple ID Server: 7 Fixes
1. Start the Settings app and tap General. · 2. Tap Transfer or Reset iPhone. · 3. Tap Reset. · 4. In the...
Read more >
An unknown error occurred when I was trying to use an iPad ...
Like anyother devices I used for development, I attached the device and pressed "Use For Development" is XCode Organizer. The process started but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found