Spring Cloud Config Server - Git - Not authorized
Asked Answered
P

6

5

I have a Spring-Boot application that use Spring Cloud Config and I'm trying to get the application's configuration file from Bitbucket. I was able to get the configuration file some time ago but now I'm getting an error when I try to access by config-server 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}'

When I try to access the url the application is showing an error - NOT AUTHORIZED:

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]

Does anybody know what is happening? I've already check all credentials and url on bitbucket.

Parameter answered 22/2, 2021 at 17:55 Comment(0)
F
0

Generate a token(classic) from developer settings in your GitHub Settings.Use that as a password and you'll be okay

Fundament answered 21/10, 2023 at 4:47 Comment(0)
O
6

I had to generate a Personal Access Token on my Github user settings. And use it, instead of the real password.

enter image description here

I know you mentioned Bitbucket, but I've got the same issue with Github instead. And that's how I solved the "Not authorized" message.

Outskirts answered 9/1, 2022 at 1:4 Comment(0)
C
1

I want to add my contribution to this question. I hope it might help someone. @henriqueor answer was what helped me. As I've enabled SSH I needed to generate a Personal Access Token with all scopes granted. (As I'm a Junior Developer, I would need more time to investigate what scopes are necessary to avoid this error.)

Selected scopes: 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, notifications, project, repo, user, workflow, write:discussion, write:packages

Coalition answered 27/8, 2022 at 19:59 Comment(0)
P
0

I needed to change the authentication to use ssh instead of https.


I generated the ssh using this command:

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

Imported the public key to bitbucket using this tutorial: https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/

And changed my application.yml to use the 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
Parameter answered 23/2, 2021 at 14:55 Comment(0)
B
0

I added the following command line. It worked for me.

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

This setting ignores the local ssh config.

Boner answered 2/8, 2021 at 7:9 Comment(0)
F
0

For BitBucket i had to create an App Password and put it in the spring.cloud.config.server.git.password property BitBucket config BitBucket create App Passwords

Flycatcher answered 8/8, 2022 at 15:26 Comment(0)
F
0

Generate a token(classic) from developer settings in your GitHub Settings.Use that as a password and you'll be okay

Fundament answered 21/10, 2023 at 4:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.