Android Studio, Github login problem incorrect credentials

Viewed 16760

I've started working with Android Studio and I found a problem when trying to connect to Github. I've tried restarting Android Studio and even creating a new project, but I am not able to login.

I installed Git and it´s working in the local repository.

The problems are:

Incorrect credentials
Request response: 401 unauthorized

Android Studio Screenshot

7 Answers

You can use the Project from Version Control, it has git.

What I did was I logged in through a token, it also tells you what needs to be added to the token and that worked for me.

You can create the token here: https://github.com/settings/tokens

Note: I found this solution on: Can't log in to GitHub on Android Studio. Such solution worked perfect for me!

On GitHub:

  • Log in -> Click on your avatar in the top right hand corner
  • Choose Settings -> Developer settings -> Personal access tokens
  • Click on the "Generate new token" button
  • Add a note if you want (in my case was mandatory), like "Android Studio"
  • Select repo(all), read:org (under admin:org), gist
  • Click on the "Generate token" button
  • Copy the token

On Android Studio:

  • Go to File -> Settings -> Version Control -> GitHub
  • Add an account (plus button on the right side, choose "log in with token")
  • Click the "Use Token" hyperlink, like in your screenshot
  • Paste your token, click login, click ok

you can install git in your operation system and use command for add your android project to github repository.

1- you should install git bash

2- open git bash in your project directory and initial it as a git repository

  • git init -b main

3- add your project to the local repository

  • git add .

4- commit your file to the local git repository

  • git commit -m "First commit"

5- Create a branch, usually called a 'main' or 'master'

  • git branch -M main

6- define remote git url

  • git remote add origin remote repository URL

7- finally, you should push all your project into remote git repository

  • git push -u origin main

Updating to AndroidStudio 4.1.1 allowed me to access with my credentials without having to generate a token.

You have to check all required settings (see image GitHub settings required) at your GitHub account at https://github.com/settings/tokens/, and then you have to update the token (You must regenerate your token if you havent copied yet).... Then you can insert your credentials again in Android Studio and... ¡ready!

Couple of issues can be there to block you from accessing your github repo and throwing 403 error. Hence please go step by step.

Step-1 : Local git is corrupted or not working

git branch -r [If it gives result you are good]

git ls-remote --heads  <remot_git_location> 

if one of the above is working then your local git is good. If not use

git config --global --unset credential.helper

Step-2 : From your IDE (IntelliJ or Android Studio etc) see git is configured and test it.

Go to Default Settings-->GitHub and Your host should be "https://github.com"

Get your Github personal token. Login to your github account from browser. Settings -> Developer settings -> Personal access tokens. o Select all “repo”, gist and “read.org” in your scope. o Create the token

Last step: If still not working, Go to VCS--> GIT --> Remotes --> Change the repo to include token explicitly

https://user_name:<your_TOKEN>@github.com/reponame.git

Paste the token in your IDE and test the connection. If your problem still persists then check if there is network issue.

Related