Мне удалось получить решение проблемы
UserCredentials.newBuilder()
.setClientId("your client id")
.setClientSecret("your client secret")
.setAccessToken("Access Token")
.build()
Вы можете передать этот объект UserCredentials в `FixedCredentialsProvider.create ())
Получить токен доступа с помощью
val client = OkHttpClient()
val requestBody = FormEncodingBuilder()
.add("grant_type", "authorization_code")
.add("client_id", "")
.add("client_secret", "")
.add("redirect_uri", "")
.add("code", "yourweb server id)
.build()
val request = Request.Builder()
.url("https://www.googleapis.com/oauth2/v4/token")
.post(requestBody)
.build()
client.newCall(request).enqueue(object : Callback {
override fun onFailure(request: Request, e: IOException) {
}
@Throws(IOException::class)
override fun onResponse(response: Response) {
try {
val jsonObject = JSONObject(response.body().string())
mTokenExpired = SystemClock.elapsedRealtime() + jsonObject.optLong("expires_in") * 1000
accessTokenObservable.postValue(Resource.success("",jsonObject.optString("access_token")))
} catch (e: JSONException) {
e.printStackTrace()
}
}
})
https://github.com/erickogi/AndroidGooglePhotosApi
Надеюсь, это поможет