-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added refresh token functionality to the non GMS lib. (#68)
- Loading branch information
Anton Tchistiakova
committed
Jul 6, 2023
1 parent
f4cbdf6
commit dcee4e6
Showing
4 changed files
with
29 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
21 changes: 21 additions & 0 deletions
21
.../main/java/com/omh/android/storage/api/drive/nongms/data/retrofit/StorageAuthenticator.kt
This file contains 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,21 @@ | ||
package com.omh.android.storage.api.drive.nongms.data.retrofit | ||
|
||
import com.omh.android.auth.api.OmhCredentials | ||
import okhttp3.Authenticator | ||
import okhttp3.Request | ||
import okhttp3.Response | ||
import okhttp3.Route | ||
|
||
internal class StorageAuthenticator(private val credentials: OmhCredentials) : Authenticator { | ||
|
||
override fun authenticate(route: Route?, response: Response): Request? { | ||
val refreshedToken = credentials.blockingRefreshToken() ?: return null | ||
return response.request | ||
.newBuilder() | ||
.header( | ||
name = GoogleRetrofitImpl.HEADER_AUTHORIZATION_NAME, | ||
value = GoogleRetrofitImpl.BEARER.format(refreshedToken) | ||
) | ||
.build() | ||
} | ||
} |
This file contains 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