Skip to content

Commit 2b80642

Browse files
author
Aidan Laing
committed
Read Me Refresh Token Code Sample
1 parent 412320a commit 2b80642

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,26 @@ Exceptions:
127127
1. If the token's refresh token is expired a `RefreshExpiredException` will be thrown in the onError of the TokenCallback. In this case the user will need to reauthenticate.
128128
2. If the token does not have a refresh token then a `NoRefreshTokenException` will be thrown in the onError of the TokenCallback. This means the Token data being returned does not contain the required refreshToken for this lib to work.
129129

130+
Calling refreshToken:
131+
```kotlin
132+
client?.refreshToken(object: MobileAuthenticationClient.TokenCallback {
133+
override fun onError(throwable: Throwable) {
134+
Log.e(tag, throwable.message)
135+
when (throwable) {
136+
is RefreshExpiredException -> {
137+
Log.e(tag, "Refresh token is expired. Please re-authenticate.")
138+
}
139+
is NoRefreshTokenException -> {
140+
Log.e(tag, "No Refresh token associated with Token")
141+
}
142+
}
143+
}
144+
145+
override fun onSuccess(token: Token) {
146+
Log.d(tag, "Refresh Token Success")
147+
deleteToken()
148+
}
149+
})
150+
```
151+
130152

0 commit comments

Comments
 (0)