Hide shikimori sensitive information
This commit is contained in:
@@ -24,6 +24,9 @@ android {
|
|||||||
arg 'room.schemaLocation', "$projectDir/schemas".toString()
|
arg 'room.schemaLocation', "$projectDir/schemas".toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildConfigField 'String', 'SHIKIMORI_CLIENT_ID', localProperty('shikimori.clientId')
|
||||||
|
buildConfigField 'String', 'SHIKIMORI_CLIENT_SECRET', localProperty('shikimori.clientSecret')
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import okhttp3.FormBody
|
|||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
|
import org.koitharu.kotatsu.BuildConfig
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import org.koitharu.kotatsu.parsers.util.await
|
import org.koitharu.kotatsu.parsers.util.await
|
||||||
import org.koitharu.kotatsu.parsers.util.json.mapJSON
|
import org.koitharu.kotatsu.parsers.util.json.mapJSON
|
||||||
@@ -14,8 +15,6 @@ import org.koitharu.kotatsu.shikimori.data.model.ShikimoriManga
|
|||||||
import org.koitharu.kotatsu.shikimori.data.model.ShikimoriMangaInfo
|
import org.koitharu.kotatsu.shikimori.data.model.ShikimoriMangaInfo
|
||||||
import org.koitharu.kotatsu.shikimori.data.model.ShikimoriUser
|
import org.koitharu.kotatsu.shikimori.data.model.ShikimoriUser
|
||||||
|
|
||||||
private const val CLIENT_ID = "Mw6F0tPEOgyV7F9U9Twg50Q8SndMY7hzIOfXg0AX_XU"
|
|
||||||
private const val CLIENT_SECRET = "euBMt1GGRSDpVIFQVPxZrO7Kh6X4gWyv0dABuj4B-M8"
|
|
||||||
private const val REDIRECT_URI = "kotatsu://shikimori-auth"
|
private const val REDIRECT_URI = "kotatsu://shikimori-auth"
|
||||||
private const val BASE_URL = "https://shikimori.one/api/"
|
private const val BASE_URL = "https://shikimori.one/api/"
|
||||||
private const val MANGA_PAGE_SIZE = 10
|
private const val MANGA_PAGE_SIZE = 10
|
||||||
@@ -26,7 +25,7 @@ class ShikimoriRepository(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
val oauthUrl: String
|
val oauthUrl: String
|
||||||
get() = "https://shikimori.one/oauth/authorize?client_id=$CLIENT_ID&" +
|
get() = "https://shikimori.one/oauth/authorize?client_id=${BuildConfig.SHIKIMORI_CLIENT_ID}&" +
|
||||||
"redirect_uri=$REDIRECT_URI&response_type=code&scope="
|
"redirect_uri=$REDIRECT_URI&response_type=code&scope="
|
||||||
|
|
||||||
val isAuthorized: Boolean
|
val isAuthorized: Boolean
|
||||||
@@ -35,8 +34,8 @@ class ShikimoriRepository(
|
|||||||
suspend fun authorize(code: String?) {
|
suspend fun authorize(code: String?) {
|
||||||
val body = FormBody.Builder()
|
val body = FormBody.Builder()
|
||||||
body.add("grant_type", "authorization_code")
|
body.add("grant_type", "authorization_code")
|
||||||
body.add("client_id", CLIENT_ID)
|
body.add("client_id", BuildConfig.SHIKIMORI_CLIENT_ID)
|
||||||
body.add("client_secret", CLIENT_SECRET)
|
body.add("client_secret", BuildConfig.SHIKIMORI_CLIENT_SECRET)
|
||||||
if (code != null) {
|
if (code != null) {
|
||||||
body.add("redirect_uri", REDIRECT_URI)
|
body.add("redirect_uri", REDIRECT_URI)
|
||||||
body.add("code", code)
|
body.add("code", code)
|
||||||
|
|||||||
@@ -23,6 +23,15 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Object localProperty(String name, Object defaultValue = 'null') {
|
||||||
|
Properties localProperties = new Properties()
|
||||||
|
project.rootProject.file('local.properties').withInputStream { localProperties.load(it) }
|
||||||
|
|
||||||
|
def value = localProperties[name]
|
||||||
|
|
||||||
|
return value != null ? value : defaultValue
|
||||||
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user