OAuth2 icon indicating copy to clipboard operation
OAuth2 copied to clipboard

Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

Open mstralka opened this issue 6 years ago • 4 comments

I created a simple proof-of-concept app (Swift 4.1 and p2_OAuth2 version 4.0.1 using a Google OAuth client.

When I tap the Login button, it opens Safari and takes me to Google for authentication. I login correctly. Then it reopens my app, but I immediately get this error in my AppDelegate:

Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

I don't see any stack trace in the console so I don't know how to debug it further.

Help appreciated! Mark

mstralka avatar Apr 08 '18 20:04 mstralka

I'm having the same problem! I would appreciate any help as well!

JacobJidell avatar Apr 11 '18 12:04 JacobJidell

I just found an answer that worked for me!

I had to add this function in the appDelegate to handle the url:

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
        OauthManager.oauth2.handleRedirectURL(url)
        return true
    }

JacobJidell avatar Apr 11 '18 13:04 JacobJidell

@JacobAhlberg thanks that worked for me too! I had this method, which worked fine up until XCode 9.3 and iOS 11.3:

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
}

Thanks for your help. Mark

mstralka avatar Apr 11 '18 20:04 mstralka

Can confirm @JacobAhlberg fix works!

joshareogun avatar Apr 16 '18 15:04 joshareogun