@ -22,6 +22,7 @@ import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import kotlinx.serialization.json.jsonPrimitive
import okhttp3.FormBody
import okhttp3.FormBody
import okhttp3.Headers
import okhttp3.OkHttpClient
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.RequestBody
@ -256,13 +257,21 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
. appendPath ( " my_list_status " )
. appendPath ( " my_list_status " )
. build ( )
. build ( )
fun refreshTokenRequest ( refreshToken: String ) : Request {
fun refreshTokenRequest ( oauth: OAuth ) : Request {
val formBody : RequestBody = FormBody . Builder ( )
val formBody : RequestBody = FormBody . Builder ( )
. add ( " client_id " , clientId )
. add ( " client_id " , clientId )
. add ( " refresh_token " , refreshT oken)
. add ( " refresh_token " , oauth. refresh _t oken)
. add ( " grant_type " , " refresh_token " )
. add ( " grant_type " , " refresh_token " )
. build ( )
. build ( )
return POST ( " $baseOAuthUrl /token " , body = formBody )
// Add the Authorization header manually as this particular
// request is called by the interceptor itself so it doesn't reach
// the part where the token is added automatically.
val headers = Headers . Builder ( )
. add ( " Authorization " , " Bearer ${oauth.access_token} " )
. build ( )
return POST ( " $baseOAuthUrl /token " , body = formBody , headers = headers )
}
}
private fun getPkceChallengeCode ( ) : String {
private fun getPkceChallengeCode ( ) : String {