DanBonehill
DanBonehill

Reputation: 145

Spring Cloud Config Server - Connect to Github account with 2FA

I'm trying to create a Spring Cloud Config Server to retrieve configuration files from a private GitHub repository. My GitHub account has 2 Factor Authentication activated so I wasn't expecting the below configuration to work, which it didn't but I can't find any documentation to suggest what I need to do in order to make it work.

What configuration do I need to set that will allow the connection to work?

spring.cloud.config.server.git.uri=https://github.com/DanBonehill/photo-app-config
spring.cloud.config.server.git.username=USERNAME
spring.cloud.config.server.git.password=PASSWORD

Error

org.eclipse.jgit.api.errors.TransportException: https://github.com/DanBonehill/photo-app-config: not authorized

Upvotes: 2

Views: 7018

Answers (4)

Hoiama Rodrigues
Hoiama Rodrigues

Reputation: 346

you solve this in 2 minutes, this problem is because at August 13, 2021 the github update the login form, to solve this.

1) login in your gitHub folow this path: Settings > Developer settings > Personal access tokens > Generate new token

2) Now set a long time to expiration token, check the "repo" to allow access repository with this token, and Generate token.

3) Now skill your github password because this token created is your new password, replace this at all application, server, terminal that need to access github.

4) Now configure your spring configuration server, this is a content of file "application.properties" of spring configuration server at path /src/main/resources/application.properties.

spring.cloud.config.server.git.uri= https://github.com/"username"/"repository" //your githur repository spring.cloud.config.server.git.search-paths= myFilesFolder /if your files is into some folder spring.cloud.config.server.git.username= testUsername // your username spring.cloud.config.server.git.password= gti_FdsweecSoUSHPsdfw //Here is your new token created

Upvotes: 0

Christina Dawoud
Christina Dawoud

Reputation: 1

Basic authentication using a password to Git is deprecated and will soon no longer work. Visit https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information around suggested workarounds and removal dates.

Upvotes: 0

Marcos Barbero
Marcos Barbero

Reputation: 1119

Instead of using username and password you should use an ssh key, the official documentation can guide you through it!

Upvotes: 3

Brendon Randall
Brendon Randall

Reputation: 1466

What you could try and do (have not tested this), is create a personal access token from the Github console.

Then configure

spring.cloud.config.server.git.username=<yourusername>
spring.cloud.config.server.git.password=<yourtoken>

Upvotes: 4

Related Questions