telenordigital / connect-ios-sdk

Docs 📒👉
https://telenordigital.github.io/id-docs.telenordigital.com/integrate-ios-sdk.html
Apache License 2.0
9 stars 8 forks source link

When having these error,it won't let me get access token until I kill the app and open again. #28

Closed thihaaung6245 closed 7 years ago

thihaaung6245 commented 7 years ago

I am experiencing these error at my log.Also on many devices which use this Telenor Connect Login Service.

error=Optional("The operation couldn’t be completed. (AGAuthzErrorDomain error 0.)")
error=Optional("The operation couldn’t be completed. (TDConnectIosSdk.OAuth2Error error 2.)")

OAuth2Error error (xxxx) codes might be different base on client situation.

State : 1 => If I open connect login page without doing anything (Idle) and login by filling appropriate form.That error appear.So,If those errors appear,I can't get access Token until I close the app,open and login again.

State : 2 => If I wrongly type my password 3 times and at the 4th time,I correctly type and went login,that error also happen too.It can also solved when I close the app and remove from multitasking.And open the app again,it worked.

I really don't know the reason why it didn't let me pass the access token when those error appear until the client close the app,remove the app from multitasking,open again and do the appropriate login steps.

Any Help?

jorunfa commented 7 years ago

Hi! I'll look at into it as soon as I can. I'm not sure I can make that happen the next couple of days, but I will as soon as possible.

jorunfa commented 7 years ago

The error sounds familiar to a bug fixed in version 0.7.2. Which version are you using?

thihaaung6245 commented 7 years ago

Yeah 0.7.1.I will check it at 0.7.2.

thihaaung6245 commented 7 years ago

error=Optional("The operation couldn’t be completed. (TDConnectIosSdk.OAuth2Error error 2.)") is still happening on Version : '0.8.0'. Can you please take a look?

jorunfa commented 7 years ago

I believe OAuth2Error error 2 is the UnequalStateParameter error. See the state parameter in the docs: http://docs.telenordigital.com/apis/connect/id/authentication.html#authorization-server-user-authorization .

It's possible it can be triggered by starting a new sign in flow before a previous one has completed. Is that a possibility?

If not, could you send a video of what is happening?

thihaaung6245 commented 7 years ago

Actually I want to but, It's rare. But,I can provide you the state.

  1. I was testing on iOS 10.1.1, iPhone 6.
  2. The SDK did correctly until it close SFSafariViewController means the authorization code didn't return and instead return this error log.
  3. Then I killed the app from memory and open it again and login the same process, it passed.
jorunfa commented 7 years ago

Try setting a breakpoint at line 99 and 108 in OAuth2Module, to inspect the state and stateFromRedirectUrl variables.

Line 99 should be called when you click the button and start a sign in. Line 108 is called when the callback to the application is called, from the redirect url. These two states must match, or else UnequalStateParameter error will be thrown.

image

thihaaung6245 commented 7 years ago

Ok I will check. In a mean while I will close this issue for now. But be right back when I got this again.