okta / okta-sdk-appauth-android

okta-sdk-appauth-android
https://github.com/okta/okta-sdk-appauth-android
Apache License 2.0
29 stars 19 forks source link

"Network Error" when properly configured #49

Open Speediing opened 5 years ago

Speediing commented 5 years ago

I have my Setup configured exactly as the readMe says and I am calling this:

    mOktaAuth!!.login(
            this,
            PendingIntent.getActivity(this, 0, completionIntent, 0),
            PendingIntent.getActivity(this, 0, cancelIntent, 0)
    )

I am instead getting a response in the logs that says:

2018-12-13 10:40:18.520 9573-9573E/OktaAppAuth: Failed to retrieve discovery document AuthorizationException: {"type":0,"code":3,"errorDescription":"Network error"}

After doing a network trace it reveals that the network request comes back correctly with a 200 response. What is going wrong?

nbarbettini commented 5 years ago

That is odd. A few quick questions:

Speediing commented 5 years ago

@nbarbettini Yes my issuer uri ends with that and yes I get a JSON document when I visit there

imbradbrown commented 5 years ago

@Speediing Was able to duplicate this on sdk 16 (4.1) produced an issue related to SSL handshake. Moving to 21 (5.0) seems to work around SSL issue.

E/AppAuth: Network error when retrieving discovery document
    javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb7e002c0: Failure in SSL library, usually a protocol error
    error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:741 0x9e135925:0x00000000)
...
Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb7e002c0: Failure in SSL library, usually a protocol error
    error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:741 0x9e135925:0x00000000)
        at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_do_handshake(Native Method)
...
E/OktaAppAuth: Failed to retrieve discovery document
    AuthorizationException: {"type":0,"errorDescription":"Network error","code":3}
Speediing commented 5 years ago

My min SDK is 21

sergiymokiyenko-okta commented 5 years ago

@Speediing did you call init() on OtaAppAuth instance before calling login() ?

Speediing commented 5 years ago

@sergiymokiyenko-okta Yes I did mOktaAuth = OktaAppAuth.getInstance(this); mOktaAuth!!.init( this, object : OktaAppAuth.OktaAuthListener { override fun onSuccess() { } override fun onTokenFailure(ex: AuthorizationException) { } })