mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[github] Better access token name
This commit is contained in:
+2
-3
@@ -37,7 +37,6 @@ import org.jetbrains.plugins.github.exceptions.GithubParseException
|
||||
import org.jetbrains.plugins.github.ui.util.DialogValidationUtils.chain
|
||||
import org.jetbrains.plugins.github.ui.util.DialogValidationUtils.notBlank
|
||||
import org.jetbrains.plugins.github.ui.util.Validator
|
||||
import org.jetbrains.plugins.github.util.GithubUtil
|
||||
import java.awt.Component
|
||||
import java.awt.Cursor
|
||||
import java.net.UnknownHostException
|
||||
@@ -71,7 +70,7 @@ class GithubLoginDialog @JvmOverloads constructor(private val executorFactory: G
|
||||
private lateinit var login: String
|
||||
private lateinit var token: String
|
||||
|
||||
var tokenNote: String = GithubUtil.DEFAULT_TOKEN_NOTE
|
||||
var clientName: String = GithubTokenCreator.DEFAULT_CLIENT_NAME
|
||||
private var tokenAcquisitionError: ValidationInfo? = null
|
||||
|
||||
init {
|
||||
@@ -277,7 +276,7 @@ class GithubLoginDialog @JvmOverloads constructor(private val executorFactory: G
|
||||
indicator: ProgressIndicator): Pair<String, String> {
|
||||
if (!isAccountUnique(loginTextField.text, server)) throw LoginNotUniqueException()
|
||||
|
||||
val token = GithubTokenCreator(server, executor, indicator).createMaster(tokenNote).token
|
||||
val token = GithubTokenCreator(server, executor, indicator).createMaster(clientName).token
|
||||
|
||||
return loginTextField.text to token
|
||||
}
|
||||
|
||||
+10
-6
@@ -1,9 +1,11 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.github.authentication.util
|
||||
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import org.jetbrains.plugins.github.api.GithubApiRequests
|
||||
import org.jetbrains.annotations.Nls
|
||||
import org.jetbrains.plugins.github.api.GithubApiRequestExecutor
|
||||
import org.jetbrains.plugins.github.api.GithubApiRequests
|
||||
import org.jetbrains.plugins.github.api.GithubServerPath
|
||||
import org.jetbrains.plugins.github.api.data.GithubAuthorization
|
||||
import org.jetbrains.plugins.github.exceptions.GithubStatusCodeException
|
||||
@@ -15,12 +17,9 @@ import java.io.IOException
|
||||
class GithubTokenCreator(private val server: GithubServerPath,
|
||||
private val executor: GithubApiRequestExecutor,
|
||||
private val indicator: ProgressIndicator) {
|
||||
|
||||
private val MASTER_SCOPES = listOf("repo", "gist")
|
||||
|
||||
@Throws(IOException::class)
|
||||
fun createMaster(note: String): GithubAuthorization {
|
||||
return safeCreate(MASTER_SCOPES, note)
|
||||
fun createMaster(@Nls(capitalization = Nls.Capitalization.Title) noteSuffix: String): GithubAuthorization {
|
||||
return safeCreate(MASTER_SCOPES, ApplicationNamesInfo.getInstance().fullProductName + " " + noteSuffix + " access token")
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
@@ -45,4 +44,9 @@ class GithubTokenCreator(private val server: GithubServerPath,
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val MASTER_SCOPES = listOf("repo", "gist")
|
||||
const val DEFAULT_CLIENT_NAME = "Github Integration Plugin"
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class GithubRepositoryEditor extends BaseRepositoryEditor<GithubRepositor
|
||||
private void generateToken() {
|
||||
GithubLoginDialog dialog = new GithubLoginDialog(GithubApiRequestExecutor.Factory.getInstance(), myProject);
|
||||
dialog.withServer(getHost(), false);
|
||||
dialog.setTokenNote("IntelliJ tasks plugin");
|
||||
dialog.setClientName("Tasks Plugin");
|
||||
if (dialog.showAndGet()) {
|
||||
myToken.setText(dialog.getToken());
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ object GithubUtil {
|
||||
@JvmField
|
||||
val LOG: Logger = Logger.getInstance("github")
|
||||
const val SERVICE_DISPLAY_NAME: String = "GitHub"
|
||||
const val DEFAULT_TOKEN_NOTE: String = "IntelliJ Plugin"
|
||||
const val GIT_AUTH_PASSWORD_SUBSTITUTE: String = "x-oauth-basic"
|
||||
|
||||
@JvmStatic
|
||||
|
||||
Reference in New Issue
Block a user