Skip to content

Commit 372c1b7

Browse files
author
Aidan Laing
committed
Read Me Authenticate
1 parent 1ce38bb commit 372c1b7

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,34 @@ val client = MobileAuthenticationClient(context, baseUrl, realmName, authEndpoin
5959
```
6060
The parameters needed for the client can all be found on your Red Hat Single Sign-On dashboard.
6161
We recommened you use a custom application schema for your redirectUri such as <NAME_OF_YOUR_APP>://android
62+
Please use the context of the activity in which you are going to call authenticate to create the client.
6263

6364
Please remember to call `client.clear()` in either `onPause()`, `onStop()` or `onDestroy()` in order to avoid memory leaks.
6465

66+
### Authenticate
67+
Authenticate will get a fresh token from Red Hat Single Sign-On after the user has entered their login credentials through a Chrome custom tab and store it locally.
68+
The result of the authenticate call can be retrieved in the `onActivityResult()` where the client was created.
69+
70+
Calling authenticate:
71+
```kotlin
72+
client.authenticate(<OPTIONAL_REQUEST_CODE>)
73+
```
74+
75+
OnActivityResult:
76+
```kotlin
77+
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
78+
super.onActivityResult(requestCode, resultCode, data)
79+
client?.handleAuthResult(requestCode, resultCode, data, object: MobileAuthenticationClient.TokenCallback {
80+
override fun onError(throwable: Throwable) {
81+
Log.e(tag, throwable.message)
82+
}
83+
override fun onSuccess(token: Token) {
84+
Log.d(tag, "Authenticate Success")
85+
}
86+
})
87+
}
88+
```
89+
6590

6691

6792

0 commit comments

Comments
 (0)