无法在 Android Studio 上登录 GitHub

如图所示,我无法登录 Android 工作室的 GitHub。

enter image description here

我重新设置了密码,尝试在服务器框中输入“ https://”,但仍然不让我进入,并显示了相同的消息。

我不能再更新我与我的团队正在进行的项目。
出于某种原因,我仍然能够提交和推回购和变化是可见的在线。

71299 次浏览

Check if you have activated 2FA on your account.

If you have (two-factor authentication), then the password you should enter would actually be a PAT (Personal Access Token), in your settings, not your GitHub account password.

Try this:

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, like "Android Studio"
  • Select repo(all), read:org (under admin:org), gist, workflow
  • Click on the "Generate token" button
  • Copy the token

On Android Studio:

  • Go to File -> Settings -> Version Control -> GitHub -> Add an account
  • Click on the "Use Token" hyperlink, like in your screenshot
  • Paste your token, click login, click ok

"Log in to GitHub" prompt

  1. Go to the https://github.com/settings/tokens
  2. Click Personal Access Token from the left menu.
  3. Select repo and gist
  4. Generate your token
  5. Paste the token to your Android Studio

Edit** in step 3, you must select (repo, gist, and read:org)

For me, after doing the token sign up using the Android studio UI in Preferences - Github also requested again username/password after doing git pull, what I did to solve it is to place my username and in password paste again the copied token

enter image description here

Steps

  • Go to github developer settings
  • Generate a new token with repo, gist, read:org privileges
  • Copy the token
  • Go to android studio preferences-github press the - sign if you have another account and press the + sign to add a new account
  • Go to the use token link
  • Paste your copied token
  • Now your account is added to the IDE, press apply and OK
  • Now do a git pull (if you already are in a repo)
  • If asking for username , place your github username
  • If asking for password, do not put your github password, instead paste again the token you created there and press enter

In the latest version of Android studio, click Use token and then Generate. Your browser will open the link and then click on Generate Token, copy the code and paste it on Android studio.

Android Studio Arctic Fox Solution (Windows 10)

I was authenticated in Android Studio Arctic Fox (Latest Version) using a personal access token, but still, I was getting this error on August 14, 2021:

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.

I generated a new access token on github.com, removed my GitHub account from Android Studio, and added the account again with the new access token. But still, it was showing the same error.

Reading other solutions on SO, I downloaded the GitHub CLI, and added my GitHub account in the windows command prompt with the access token successfully, and tried to push the repo from Android Studio again, which again failed.

Then following this article, I did the following in command line:

cd <project-directory>
git remote set-url origin https://<TOKEN>@github.com/<user_name>/<repo_name>.git

Pushed again from Android Studio. It worked finally!

Login with password deprecated, please use below method

In Mac Change Token --> Android Studio --> preferences --> Version Control --> GitHub --> Change Token

In GitHub Account GitHub Generate Token --> Settings --> Developer Settings --> Personal Access Token

Go to Settings > Version Control > Git > Mark the "Use credential Helper" box and you're done.

For me login didn't work had to remove existing github profile in android studio and add again with renewed token