1
0
mirror of https://github.com/tateisu/SubwayTooter synced 2025-01-26 16:56:28 +01:00

fix #156, Subway Tooter requests grant type client_credentials when trying to connect to Friendica

This commit is contained in:
tateisu 2021-05-13 22:03:29 +09:00
parent 888ea8bbd2
commit 37d073ce77

View File

@ -138,13 +138,13 @@ class TootApiClient(
fun simplifyErrorHtml(
response: Response,
caption:String = "?",
bodyString:String =response.body?.string() ?: "",
caption: String = "?",
bodyString: String = response.body?.string() ?: "",
jsonErrorParser: (json: JsonObject) -> String? = DEFAULT_JSON_ERROR_PARSER
) = TootApiResult(
response = response,
caption = caption,
).simplifyErrorHtml( bodyString,jsonErrorParser)
).simplifyErrorHtml(bodyString, jsonErrorParser)
}
// 認証に関する設定を保存する
@ -965,10 +965,18 @@ class TootApiClient(
var client_credential = client_info.string(KEY_CLIENT_CREDENTIAL)
if (client_credential?.isEmpty() != false) {
val resultSub = getClientCredential(client_info)
client_credential = resultSub?.string
if (client_credential?.isEmpty() != false) return resultSub
client_info[KEY_CLIENT_CREDENTIAL] = client_credential
if (resultSub?.response?.code == 422) {
// https://github.com/tateisu/SubwayTooter/issues/156
// some servers not support to get client_credentials.
// just ignore error and skip.
} else if (resultSub == null || resultSub.error != null) {
return resultSub
} else {
resultSub.string?.notEmpty()?.let {
client_credential = it
client_info[KEY_CLIENT_CREDENTIAL] = it
}
}
}
try {