-
Notifications
You must be signed in to change notification settings - Fork 647
Mds/okta 524282/okta 528021 update mobile sdk overview #4332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
0a4b1c6
1ae0c6c
5785b8e
2d285d4
88b0ae4
6f940f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
mauricesharp-okta marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
|
|
||
| Initialize AuthFoundationBootstrap in your `Application` sublcass. This code shows loading the values from a property file in your project. | ||
|
||
|
|
||
| First, create a property file, for example, `okta.properties` in the project root. Add the values for your Okta application integration to the file. | ||
mauricesharp-okta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ``` | ||
mauricesharp-okta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| discoveryUrl=https://{yourIssuerUrl}/oauth2/default/.well-known/openid-configuration | ||
| clientId={yourClientId} | ||
| redirectUri=com.okta.sample.android:/login | ||
| ``` | ||
|
|
||
| Add this configuration to your `app/build.gradle` to make the properties available in the build configuration: | ||
|
|
||
| ```gradle | ||
| def oktaProperties = new Properties() | ||
| rootProject.file("okta.properties").withInputStream { oktaProperties.load(it) } | ||
| defaultConfig { | ||
| ... | ||
| buildConfigField "String", 'DISCOVERY_URL', "\"${oktaProperties.getProperty('discoveryUrl')}\"" | ||
| buildConfigField "String", 'CLIENT_ID', "\"${oktaProperties.getProperty('clientId')}\"" | ||
| buildConfigField "String", 'REDIRECT_URI', "\"${oktaProperties.getProperty('redirectUri')}\"" | ||
| ... | ||
| } | ||
| ``` | ||
|
|
||
| In your `Applicaiton` subclass, initialize `AuthFoundationBootstrap` from the `BuildConfig` by calling `initializeAuthFoundation` from `onCreate`. | ||
rajdeepnanua-okta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```kotlin | ||
| import com.okta.android.samples.authenticator.BuildConfig | ||
| import com.okta.authfoundation.AuthFoundationDefaults | ||
| import com.okta.authfoundation.client.OidcClient | ||
| import com.okta.authfoundation.client.OidcConfiguration | ||
| import com.okta.authfoundation.client.SharedPreferencesCache | ||
| import com.okta.authfoundation.credential.CredentialDataSource.Companion.createCredentialDataSource | ||
| import com.okta.authfoundationbootstrap.CredentialBootstrap | ||
| import okhttp3.HttpUrl.Companion.toHttpUrl | ||
|
|
||
| fun initializeAuthFoundation() { | ||
| // Initializes Auth Foundation and Credential Bootstrap classes. | ||
| AuthFoundationDefaults.cache = SharedPreferencesCache.create(this) | ||
| val oidcConfiguration = OidcConfiguration( | ||
| clientId = BuildConfig.CLIENT_ID, | ||
| defaultScope = "openid email profile offline_access", | ||
| ) | ||
| val client = OidcClient.createFromDiscoveryUrl( | ||
| oidcConfiguration, | ||
| BuildConfig.DISCOVERY_URL.toHttpUrl(), | ||
| ) | ||
| CredentialBootstrap.initialize(client.createCredentialDataSource(this)) | ||
| } | ||
| ``` | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <div class="full"> | ||
|
|
||
|  | ||
|
|
||
| </div> | ||
|
|
||
| The main objects associated with each step in the flow are: | ||
|
|
||
| | Sign-in step | Objects | | ||
| | :--------------------------------- |:---------------------------------| | ||
| | Initialize SDK | InteractionCodeFlow | | ||
| | Request initial step | InteractionCodeFlow | | ||
| | Receive step | IdxResponse | | ||
| | Check completion, cancel, or error | IdxResponse <br/> IdxRemediation | | ||
| | Gather user input | IdxRemediation <br/> Capability | | ||
| | Send input | InteractionCodeFlow | | ||
| | Done | IdxResponse | | ||
mauricesharp-okta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,42 +1,21 @@ | ||||||||
| This code assumes storing the access token after a successful sign-in flow: | ||||||||
|
|
||||||||
| ```kotlin | ||||||||
| import com.okta.authfoundation.client.OidcClientResult | ||||||||
| import com.okta.authfoundation.credential.RevokeTokenType | ||||||||
| import com.okta.authfoundationbootstrap.CredentialBootstrap | ||||||||
|
|
||||||||
| fun logout() { | ||||||||
| viewModelScope.launch(Dispatchers.IO) { | ||||||||
| try { | ||||||||
| // First load a refresh token if one exists. | ||||||||
| val refreshToken = Storage.tokens.refreshToken | ||||||||
| if (refreshToken != null) { | ||||||||
| // Revoking the refresh token also revokes the access token. | ||||||||
| revokeToken("refresh_token", refreshToken) | ||||||||
| } else { | ||||||||
| revokeToken("access_token", Storage.tokens.accessToken) | ||||||||
| viewModelScope.launch { | ||||||||
| // Revoking the refresh token also revokes the access token. | ||||||||
| when (val revokeResult = CredentialBootstrap.defaultCredential().revokeToken(RevokeTokenType.REFRESH_TOKEN)) { | ||||||||
|
||||||||
| when (val revokeResult = CredentialBootstrap.defaultCredential().revokeToken(RevokeTokenType.REFRESH_TOKEN)) { | |
| when (val revokeResult = CredentialBootstrap.defaultCredential() | |
| .revokeToken(RevokeTokenType.REFRESH_TOKEN)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did the best I could... in the next commit.
Uh oh!
There was an error while loading. Please reload this page.