-
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
Open
mauricesharp-okta
wants to merge
6
commits into
master
Choose a base branch
from
mds/OKTA-524282/OKTA-528021-update-mobile-sdk-overview
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0a4b1c6
Initial updates
mauricesharp-okta 1ae0c6c
Updates to Android content
mauricesharp-okta 5785b8e
Updated code and text for new SDK
mauricesharp-okta 2d285d4
Clean up wording in a few areas
mauricesharp-okta 88b0ae4
Incoroprate review comments
mauricesharp-okta 6f940f9
Incorporate review round 2
mauricesharp-okta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file modified
BIN
-79 Bytes
(100%)
...okta/vuepress-site/.vuepress/public/img/mobile-sdk/mobile-idx-basic-objects.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+34.9 KB
...ess-site/.vuepress/public/img/mobile-sdk/mobile-idx-objects-and-flow-kotlin.png
mauricesharp-okta marked this conversation as resolved.
Show resolved
Hide resolved
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+33.4 KB
...ress-site/.vuepress/public/img/mobile-sdk/mobile-idx-objects-and-flow-swift.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-32.2 KB
...a/vuepress-site/.vuepress/public/img/mobile-sdk/mobile-idx-objects-and-flow.png
Binary file not shown.
15 changes: 9 additions & 6 deletions
15
...vuepress-site/docs/guides/mobile-idx-sdk-overview/main/android/gettingatoken.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...uepress-site/docs/guides/mobile-idx-sdk-overview/main/android/initializeflow.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
|
|
||
| The following example loads the configuration values for the flow 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 app integration to the file. | ||
|
|
||
| ```properties | ||
| 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 `Application` subclass, initialize `AuthFoundationBootstrap` from the `BuildConfig` by calling `initializeAuthFoundation` from `onCreate`. | ||
|
|
||
| ```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)) | ||
| } | ||
| ``` |
29 changes: 19 additions & 10 deletions
29
...site/docs/guides/mobile-idx-sdk-overview/main/android/initializingsdksession.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
...-site/docs/guides/mobile-idx-sdk-overview/main/android/loadingaconfiguration.md
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
...uepress-site/docs/guides/mobile-idx-sdk-overview/main/android/objectsandflow.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 15 additions & 33 deletions
48
...ta/vuepress-site/docs/guides/mobile-idx-sdk-overview/main/android/signingout.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,24 @@ | ||
| 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) | ||
| ) | ||
| { | ||
| is OidcClientResult.Error -> { | ||
| // Sign-out failed, handle the error. | ||
| } | ||
| is OidcClientResult.Success -> { | ||
| // Sign-out successful. Redirect to a sign-in view. | ||
| } | ||
|
|
||
| // Sign-out successful. Redirect to a sign-in view. | ||
| } catch (e: Exception) { | ||
| // Sign-out failed, handle the error. | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| private fun revokeToken(tokenType: String, token: String) { | ||
| // Create an API request to revoke the token. | ||
| val formBody = FormBody.Builder() | ||
| .add("client_id", BuildConfig.CLIENT_ID) | ||
| .add("token_type_hint", tokenType) | ||
| .add("token", token) | ||
| .build() | ||
|
|
||
| val request = Request.Builder() | ||
| .url("${BuildConfig.ISSUER}/v1/revoke") | ||
| .post(formBody) | ||
| .build() | ||
|
|
||
| // Send the request to revoke the token. | ||
| val response = OktaIdxClientConfigurationProvider.get().okHttpCallFactory.newCall(request).execute() | ||
|
|
||
| println("Revoke Token Response: $response") | ||
| } | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.