Spring Cloud 配置服务器 - Git - 未授权

问题描述 投票:0回答:6

我有一个使用 Spring Cloud Config 的 Spring-Boot 应用程序,我正在尝试从 Bitbucket 获取应用程序的配置文件。我不久前能够获取配置文件,但现在当我尝试通过配置服务器 url 访问时出现错误。

application.yml:

server:
    port: 8888
spring:
    application:
        name: config-server
    cloud:
        config:
            server:
                git:
                    password: ##########
                    username: ##########
                    uri: https://[email protected]/repositorios-closeup/cup-configuration-files
                    searchPaths: '{application}'

当我尝试访问该网址时,应用程序显示错误 - 未授权

org.eclipse.jgit.api.errors.TransportException: https://[email protected]/repositorios-closeup/cup-configuration-files: not authorized

    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:254) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
    at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:306) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]

有人知道发生了什么事吗?我已经检查了 bitbucket 上的所有凭据和 url。

spring-boot bitbucket spring-cloud-config
6个回答
6
投票

我必须在我的 Github 用户设置上生成个人访问令牌。并使用它,而不是真正的密码。

我知道你提到了 Bitbucket,但我在 Github 上也遇到了同样的问题。这就是我解决“未授权”消息的方法。


1
投票

我想对这个问题添加我的贡献。我希望它可以帮助某人。 @henriqueor 答案对我有帮助。由于我启用了 SSH,因此我需要生成一个具有授予所有范围的个人访问令牌。 (由于我是初级开发人员,我需要更多时间来调查避免此错误所需的范围。)

选定范围:admin:enterprise、admin:gpg_key、admin:org、admin:org_hook、admin:public_key、admin:repo_hook、admin:ssh_signing_key、delete:packages、delete_repo、gist、通知、项目、repo、用户、工作流程,写:讨论,写:包


0
投票

我添加了以下命令行。这对我有用。

spring.cloud.config.server.git.ignore-local-ssh-settings=true

此设置忽略本地 ssh 配置。


0
投票

我需要更改身份验证以使用 ssh 而不是 https。


我使用以下命令生成了 ssh:

sh-keygen -m PEM -t rsa -b 4096 -C 'bitbucket_username'

使用本教程将公钥导入到 bitbucket: https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/

并更改了我的 application.yml 以使用 ssh-private-key:

    cloud:
        config:
            server:
                git:
                    uri: [email protected]:repositorios/configuration-files.git
                    searchPaths: '{application}'
                    ignore-local-ssh-settings: true
                    private-key: |
                        -----BEGIN RSA PRIVATE KEY-----
                        ...
                        -----END RSA PRIVATE KEY-----
                    default-label: master

0
投票

对于 BitBucket,我必须创建一个 App Password 并将其放入

spring.cloud.config.server.git.password
属性中 BitBucket 创建应用程序密码


0
投票

从 GitHub 设置中的开发者设置生成令牌(经典)。使用它作为密码就可以了

© www.soinside.com 2019 - 2024. All rights reserved.