From dcf4fb478cb55086fa5c01df1e6839c7faacc693 Mon Sep 17 00:00:00 2001 From: Abby Berkers Date: Sun, 17 Jul 2022 17:00:11 +0200 Subject: [PATCH] Add libraries icon --- resources/META-INF/extensions/tool-windows.xml | 3 ++- .../mendeley/MendeleyAuthenticator.kt | 10 ++++++++-- .../mendeley/MendeleyCredentials.kt | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/nl/hannahsten/texifyidea/remotelibraries/mendeley/MendeleyCredentials.kt diff --git a/resources/META-INF/extensions/tool-windows.xml b/resources/META-INF/extensions/tool-windows.xml index ef00d04ad..c99c62218 100644 --- a/resources/META-INF/extensions/tool-windows.xml +++ b/resources/META-INF/extensions/tool-windows.xml @@ -1,10 +1,11 @@ + - diff --git a/src/nl/hannahsten/texifyidea/remotelibraries/mendeley/MendeleyAuthenticator.kt b/src/nl/hannahsten/texifyidea/remotelibraries/mendeley/MendeleyAuthenticator.kt index e58797d28..7f7881112 100644 --- a/src/nl/hannahsten/texifyidea/remotelibraries/mendeley/MendeleyAuthenticator.kt +++ b/src/nl/hannahsten/texifyidea/remotelibraries/mendeley/MendeleyAuthenticator.kt @@ -58,7 +58,7 @@ object MendeleyAuthenticator { val authorizationServer: NettyApplicationEngine = embeddedServer(Netty, port = port) { routing { get("/") { - this.call.respondText("You are now logged in to Mendeley.") + this.call.respondText("You are now logged in to Mendeley. Click OK to continue.") authenticationCode = call.parameters["code"] serverRunning = false this.application.dispose() @@ -113,14 +113,20 @@ object MendeleyAuthenticator { append("refresh_token", PasswordSafe.instance.getPassword(refreshTokenAttributes)!!) append("redirect_uri", "http://localhost:$port/") }) { - basicAuth(Mendeley.id, Mendeley.secret) + basicAuth(MendeleyCredentials.id, MendeleyCredentials.secret.decipher()) }.body() + println(MendeleyCredentials.secret) val (tokenCredentials, refreshTokenCredentials) = token.getCredentials() return BearerTokens(tokenCredentials.password.toString(), refreshTokenCredentials.password.toString()) } + /** + * Decipher the Mendeley secret... + */ + private fun String.decipher() = toCharArray().map { it.minus(12) }.joinToString("") + /** * Data class to deserialize Mendeley's response with the access token. */ diff --git a/src/nl/hannahsten/texifyidea/remotelibraries/mendeley/MendeleyCredentials.kt b/src/nl/hannahsten/texifyidea/remotelibraries/mendeley/MendeleyCredentials.kt new file mode 100644 index 000000000..3ac5dfd54 --- /dev/null +++ b/src/nl/hannahsten/texifyidea/remotelibraries/mendeley/MendeleyCredentials.kt @@ -0,0 +1,14 @@ +package nl.hannahsten.texifyidea.remotelibraries.mendeley + +object MendeleyCredentials { + + /** + * TeXiFy id to communicate with Mendeley. + */ + const val id = "13058" + + /** + * TeXiFy secret to communicate with Mendeley. + */ + const val secret = "\u0084BA\\U\u0086sTWx`MpuMT" +} \ No newline at end of file