abdenacer
abdenacer

Reputation: 1

spring cloud config server unable to connect to private git repository (not authorized)

I want to use private git repository with my config server. Here is my application.properties:

spring.application.name=PhotoAppApiConfigServer
server.port=8012
spring.cloud.config.server.git.uri=https://github.com/nasrouu/PhotoAppConfiguration.git
spring.cloud.config.server.git.username=myusername
spring.cloud.config.server.git.password=mypassword

spring.cloud.config.server.git.clone-on-start=true
spring.cloud.config.server.git.default-label=main

management.endpoints.web.exposure.include=busrefresh

spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

I get the following error:

Error occured cloning to base directory

org.eclipse.jgit.api.errors.TransportException:
https://github.com/nasrouu/PhotoAppConfiguration.git: not authorized

application.properties for my private github repositorie

gateway.ip=192.168.2.82
token.expiration_time=864000000
token.secret=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9eyJpZCI6IjVjOWYzYW
I2NzY2Mjg2NDYyNDY0YTczNCIsIm5hbWUiOiJSYW5keSIsImF2YXRhciI6I
i8vd3d3LmdyYXZhdGFyLmNvbS9hdmF0YXIvMTNhN2MyYzdkOGVk 
NTNkMDc2MzRkOGNlZWVkZjM0NTEcz0yMDAmcj1wZyZkPW1tIiwi
aWF0IjoxNTU0NTIxNjk1LCJleHAiOjE1NTQ1MjUyOTV9SxRurShXSSI3SE11z6nme9EoaD2
9TDBFr8Qwngkg
login.url.path=/users/login

How should I fix it?

Upvotes: 0

Views: 1099

Answers (2)

jose liza
jose liza

Reputation: 41

you must create a personal access token https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

then you copy the generated token as del key into the config file aplicación.propiedades. For example:

spring.cloud.config.server.git.clone-on-start=true
spring.cloud.config.server.git.uri=https://github.com/joselizagaravito/RepositoryDemo
spring.cloud.config.server.git.username=myusername
spring.cloud.config.server.git.password=ghp_1234D4omMscbwOMydb123423463

Upvotes: 1

Noman
Noman

Reputation: 303

You can also do this using github and the new fine grained access token generated from github. In that case the username and password both must be set to the same token generated.

spring:
  application:
    name: config-service
  cloud:
    config:
      server:
        git:
          uri: https://github.com/UserName/PrivateRepo
          username: github_fine_access_token_xxxx
          password: github_fine_access_token_xxxx
         

Upvotes: 0

Related Questions