okta / okta-oidc-android

OIDC SDK for Android
https://github.com/okta/okta-oidc-android
Other
60 stars 45 forks source link

Sample app crashes, couldn't find config #261

Closed GeforceA closed 2 years ago

GeforceA commented 2 years ago

Hi,

I download the app and put the my app config values in the res/raw/okta_oidcconfig.json file. they look like this: "client_id": "0oaw8w2glhCDnGa9Z0h7", "redirect_uri": "xamarintest.xxxx.login:/callback", "end_session_redirect_uri": "xamarintest.xxxx.logout:/callback", "scopes": [ "openid", "profile", "offline_access" ], "discoveryuri": "https://loginpreview.xxxx.com" when I try to launch the app, it crashes with this info: 2021-08-13 09:28:03.474 31004-31004/com.okta.oidc.example E/AndroidRuntime: FATAL EXCEPTION: main Process: com.okta.oidc.example, PID: 31004 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.okta.oidc.example/com.okta.oidc.example.SampleActivity}: java.lang.IllegalArgumentException: Your Okta URL is missing. You can copy your domain from the Okta Developer Console. Follow these instructions to find it: https://bit.ly/finding-okta-domain it looks like it could not find my config.
Am I missing some steps before i can run the sample code? Thanks.

GeforceA commented 2 years ago

the discovery_uri is the value from our okta preview account. I tried to use xxxx.oktapreview.com and had the same result.

JayNewstrom commented 2 years ago

Hi @GeforceA if you're looking for a sample app, I'd suggest looking at our sample apps repo.

When I run this repo, I add these to my local.properties file.

test.scheme=com.okta.dev-xxx
test.discoveryUri="https://dev-xxx.okta.com/oauth2/default"
test.clientId="xxx"
test.scopes="openid", "profile", "offline_access"
test.endSessionUri="com.okta.dev-xxx:/logoutCallback"
test.redirectUri="com.okta.dev-xxx:/callback"

The reason the config file you changed isn't working is due to it being overridden right away. See https://github.com/okta/okta-oidc-android/blob/master/app/src/main/java/com/okta/oidc/example/SampleActivity.java#L403-L415

You could also comment out lines 409-415 to try with the config file approach.

GeforceA commented 2 years ago

Thanks for the quick reply again Jay. I will check out the sample you referring to. I also did a bit debugging and the exception is actually thrown right before the code part you pointing out. on line 397, where it trying to use values in BuildConfig.DISCOVERY_URI, which is coming from the default config somewhere and it contains an empty string and that is where the exception is thrown.

JayNewstrom commented 2 years ago

Ahh yeah, sorry, I forgot about that. You'll need to use the properties mentioned above in the local.properties file in order to run the test app in this repo for now.

JayNewstrom commented 2 years ago

@GeforceA is there anything else we can help you with, or can this be closed?

GeforceA commented 2 years ago

Thanks Jay, it's all good. You can close this.

On Tue., Oct. 5, 2021, 3:50 p.m. Jay Newstrom, @.***> wrote:

@GeforceA https://github.com/GeforceA is there anything else we can help you with, or can this be closed?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/okta/okta-oidc-android/issues/261#issuecomment-934897605, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATAE6B3SDZMXTHUH2N3RKCTUFNXLDANCNFSM5CD2TH5Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.