Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't enter password in Windows #671

Closed
mathstar13 opened this issue Jul 13, 2020 · 49 comments
Closed

Can't enter password in Windows #671

mathstar13 opened this issue Jul 13, 2020 · 49 comments
Labels
support Users asking for help using twine

Comments

@mathstar13
Copy link

mathstar13 commented Jul 13, 2020

Your Environment

Thank you for taking the time to report an issue.

To more efficiently resolve this issue, we'd like to know some basic information about your system and setup.

  1. Windows 10

  2. Python 3.8.2

  3. I used pip.(pip install twine)

  4. I don't know

  5. https://github.com/mathstar13/easyapi

If you're having issues uploading a specific package, you must include a copy of the following:

  • The package's PKG-INFO file
  • A redacted version of your .pypirc file (REMOVE ALL USERNAMES & PASSWORDS BEFORE UPLOADING)

The Issue

The issue is that every time I try to upload, I enter __token__ in username, but I can't enter ANY text in the password field.

Steps to Reproduce

Use wheel on setup.py
Type in python -m twine upload --repository testpypi dist/*
type in __token__ as the username
Try to type in the password

@mathstar13
Copy link
Author

Token had two underscores before and after it.

@bhrutledge bhrutledge added the support Users asking for help using twine label Jul 14, 2020
@bhrutledge
Copy link
Contributor

@mathstar13 The password prompt doesn't show any characters while you type. For the PyPI token, I recommend copying & pasting it when you see the password prompt, and then pressing "Enter". If that doesn't work, can you copy and paste the output from Twine?

Also, I edited your description to make __token__ show up properly.

@mathstar13
Copy link
Author

mathstar13 commented Jul 14, 2020

python -m twine upload --repository testpypi dist/*
Uploading distributions to https://test.pypi.org/legacy/
Enter your username: __token__
Enter your password:
Uploading easyapi_myusername-0.0.1-py3-none-any.whl
100%|█████████████████████████████████████████████████████████████████████████████| 6.62k/6.62k [00:00<00:00, 21.4kB/s]
NOTE: Try --verbose to see response content.
HTTPError: 403 Forbidden from https://test.pypi.org/legacy/
Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.

@sigmavirus24
Copy link
Member

If only we had variable debug level logging that could help us validate that the windows version of getpass is working correctly in this case: https://github.com/python/cpython/blob/b4cd77de05e5bbaa6a4be90f710b787e0790c36f/Lib/getpass.py#L97

@bhrutledge
Copy link
Contributor

@mathstar13 Are you sure you're using the token for TestPyPI? As noted at https://test.pypi.org/help/#invalid-auth:

PyPI and TestPyPI each require you to create an account, so your credentials may be different.

@bhrutledge
Copy link
Contributor

If only we had variable debug level logging

@sigmavirus24 I agree that more information about credentials would be useful, which is why I added that to the verbosity roadmap in #381 (comment) yesterday morning.

@mathstar13
Copy link
Author

@bhrutledge I saved it in a file and tried to use it before I created a pypi token. I'm sure then that I used the right one.

@sigmavirus24
Copy link
Member

@mathstar13 can you validate that the standard library works for you?

python -c 'import getpass; print(getpass.getpass("Test: "))'

Should print whatever you type in even though you won't see it in the terminal as you type it. You don't need to copy/paste it here. Please also test that however you're inputting your token works as well in the same fashion.

@mathstar13
Copy link
Author

mathstar13 commented Jul 25, 2020

@sigmavirus24 When I try to run it, it tells me'

File "<string>", line 1
    'import
          ^
SyntaxError: EOL while scanning string literal

@sigmavirus24
Copy link
Member

Maybe adjust it for your windows terminal? The example I posted works on a *nix box but I haven't used windows in too long to remember how to write that appropriately

@bhrutledge
Copy link
Contributor

I went down the rabbit hole, installed Windows on a virtual machine, and was able to reproduce this when trying to paste the token in Command Prompt or PowerShell. In short, this is a known issue with getpass (and anything that uses it, like Twine) on Windows. The workarounds include:

  • Clicking Edit > Paste from the Command Prompt menu
  • Enabling Properties > Options > Use Ctrl+Shift+C/V as Copy/Paste in the Command Prompt menu
  • Using the new Windows Terminal

@mathstar13 Can you confirm that one of these works for you?

To reproduce, I copied the text pypi-token, and then ran this code to print the length of the entered value:

C:\Users\brian>python -c "import getpass; print(len(getpass.getpass()))"
Password: <ctrl+v><enter>
1

C:\Users\brian>python -c "import getpass; print(len(getpass.getpass()))"
Password: <ctrl+shift+v><enter>
10

Typing works fine:

C:\Users\brian>python -c "import getpass; print(len(getpass.getpass()))"
Password: pypi-token
10

However, I suspect more folks are running into this due to the use of tokens that are difficult to type.

Aside: the SyntaxError in #671 (comment) is due to the single quote; apparently it needs to be a double quote.

@mathstar13
Copy link
Author

@bhrutledge @sigmavirus24 Thanks for helping me out! I got my package uploaded!

@bhrutledge
Copy link
Contributor

That's great, @mathstar13. Out of curiosity: did one of the workarounds I suggested work for you? If so, which one?

@mathstar13
Copy link
Author

@bhrutledge The one that helped me the best was just the one that showed me getpass. I couldn't paste my token, but I could enter my username and password.

@bhrutledge
Copy link
Contributor

@mathstar13 Oh, I see. So, you just typed your username/password for TestPyPI directly? I was hoping you'd be able to paste your token. Did you try any of the workarounds that I suggested for pasting?

@mathstar13
Copy link
Author

@bhrutledge I couldn't use them because I'm in command prompt, not Windows Terminal.

@bhrutledge
Copy link
Contributor

@mathstar13 One of these options should work from Command Prompt:

  1. Clicking Edit > Paste from the Command Prompt menu
  2. Enabling Properties > Options > Use Ctrl+Shift+C/V as Copy/Paste in the Command Prompt menu
  3. Use right-click to paste

Here's an example of option 1 working for me:

Kapture 2020-08-18 at 12 06 56

In the interest of enabling you to use your token (which is better than username/password) and assisting future Windows Python developers, would you be game to give one of those options a try?

@mathstar13
Copy link
Author

@bhrutledge 1 works fine.

@bhrutledge bhrutledge mentioned this issue Aug 19, 2020
1 task
@bhrutledge
Copy link
Contributor

This gotcha feels worth documenting to me, along with a suggested workaround. I can think of a few places to do it, but I'm leaning towards adding it to https://pypi.org/help/#invalid-auth.

@mathstar13 would that have been helpful to you? Do you have other suggestions on where/how to document it?

@di what do you think?

@mathstar13
Copy link
Author

mathstar13 commented Aug 22, 2020

@bhrutledge That would be a good spot to document it. Also, maybe it should be documented in https://packaging.python.org/tutorials/packaging-projects/ if possible. If four people have reported it that I see, maybe others have tried to upload using twine and have been unable to do so.

@sigmavirus24
Copy link
Member

If four people found it, maybe others can't figure it out.

I don't understand this. Brian and I are both maintainers here. I'm for documenting this, but I'm not sure who the fourth person is here.

@mathstar13
Copy link
Author

@sigmavirus24 The four people that reported the issue are pypa/packaging-problems#384 pypa/packaging-problems#376 pypa/packaging-problems#355. Sorry that I was unclear about that. I updated my comment.

@bhrutledge
Copy link
Contributor

This is now documented at https://pypi.org/help/#invalid-auth.

I'm optimistic that the additional logging in #685 will also help folks diagnose this issue.

@IVN-tone
Copy link

@mathstar13 One of these options should work from Command Prompt:

  1. Clicking Edit > Paste from the Command Prompt menu
  2. Enabling Properties > Options > Use Ctrl+Shift+C/V as Copy/Paste in the Command Prompt menu
  3. Use right-click to paste

Here's an example of option 1 working for me:
Kapture 2020-08-18 at 12 06 56
In the interest of enabling you to use your token (which is better than username/password) and assisting future Windows Python developers, would you be game to give one of those options a try?

doesn't work for me((

@bhrutledge bhrutledge changed the title Can't enter password Can't enter password in Windows Aug 31, 2021
@bhrutledge
Copy link
Contributor

bhrutledge commented Aug 31, 2021

@IVN-tone following up from #804:

Did you try all 3 options that I listed? Did you read the suggestions at https://pypi.org/help/#invalid-auth?

Can you try running python -m twine upload --verbose --repository testpypi dist/* and pasting entire the output here?

but you also closed the issue #671 and still no solution for the current problem.

This issue is closed because thus far, we haven't identified anything that should be changed in Twine. The resolution has always had to do with pasting text in the Windows command prompt, which is documented at https://pypi.org/help/#invalid-auth. If that doesn't work, we can re-open this, or #804, but for now, I think it's useful to keep the conversation in one place, for future reference.

@IVN-tone
Copy link

@IVN-tone following up from #804:

Did you try all 3 options that I listed? Did you read the suggestions at https://pypi.org/help/#invalid-auth?

Can you try running python -m twine upload --verbose --repository testpypi dist/* and pasting entire the output here?

but you also closed the issue #671 and still no solution for the current problem.

This issue is closed because thus far, we haven't identified anything that should be changed in Twine. The resolution has always had to do with pasting text in the Windows command prompt, which is documented at https://pypi.org/help/#invalid-auth. If that doesn't work, we can re-open this, or #804, but for now, I think it's useful to keep the conversation in one place, for future reference.

Ok, I'll try it first and give the feedback, thank you!

@IVN-tone

This comment has been minimized.

@IVN-tone
Copy link

@IVN-tone following up from #804:
Did you try all 3 options that I listed? Did you read the suggestions at https://pypi.org/help/#invalid-auth?

I tried all the instructions at https://pypi.org/help/#invalid-auth - nothing helped me.

@bhrutledge
Copy link
Contributor

@IVN-tone I need you to copy and paste the entire output of python -m twine upload --verbose --repository testpypi dist/*, not just selected pieces of it. If that's difficult or not possible, a screenshot will suffice.

For example, here's what happens when I use the wrong token for "Enter your password":

% python -m twine upload --verbose --repository testpypi dist/*
Using configuration from /Users/bhrutledge/.pypirc
Uploading distributions to https://test.pypi.org/legacy/
  dist/example_pkg_bhrutledge-0.0.5-py3-none-any.whl (2.6 KB)
  dist/example-pkg-bhrutledge-0.0.5.tar.gz (2.2 KB)
username set from config file
Enter your password: 
username: __token__
password: <hidden>
Uploading example_pkg_bhrutledge-0.0.5-py3-none-any.whl
100%|██████████████████████████████████████████████████████████████████████████████| 5.98k/5.98k [00:00<00:00, 25.8kB/s]
Content received from server:
<html>
 <head>
  <title>403 Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.</title>
 </head>
 <body>
  <h1>403 Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.</h1>
  Access was denied to this resource.<br/><br/>
Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.


 </body>
</html>
HTTPError: 403 Forbidden from https://test.pypi.org/legacy/
Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.

@IVN-tone

This comment has been minimized.

@bhrutledge

This comment has been minimized.

@IVN-tone
Copy link

@IVN-tone You didn't include the --verbose option. Please run:

python -m twine upload --verbose --repository testpypi dist/*

Ok, done:

>python -m twine upload --verbose --repository testpypi dist/*
Uploading distributions to https://test.pypi.org/legacy/
  dist\test1-0.0.1-py3-none-any.whl (2.5 KB)
  dist\test1-0.0.1.tar.gz (1.9 KB)
Enter your username: __token__
Enter your password:
username: __token__
password: <hidden>
Uploading test1-0.0.1-py3-none-any.whl
100%|█████████████████████████████████████| 5.80k/5.80k [00:00<00:00, 7.97kB/s]
Content received from server:
<html>
 <head>
  <title>403 Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.</title>
 </head>
 <body>
  <h1>403 Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.</h1>
  Access was denied to this resource.<br/><br/>
Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.


 </body>
</html>
HTTPError: 403 Forbidden from https://test.pypi.org/legacy/
Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.

@bhrutledge
Copy link
Contributor

Okay, the password: <hidden> line tells me that you've successfully pasted a password, which leads me to believe that the value you've entered is not the correct token for TestPyPI. I'm not sure how else to debug that, short of suggesting that you triple-check the value that you're pasting, and maybe have a friend or colleague watch as you go through all the steps.

@IVN-tone
Copy link

IVN-tone commented Aug 31, 2021

Okay, the password: <hidden> line tells me that you've successfully pasted a password, which leads me to believe that the value you've entered is not the correct token for TestPyPI. I'm not sure how else to debug that, short of suggesting that you triple-check the value that you're pasting, and maybe have a friend or colleague watch as you go through all the steps.

I just press the button Copy token at (https://test.pypi.org/manage/account/token/) and paste it in the field password of the command prompt.

Ctrl+V\Ctrl+C is enabled in my command prompt, I tried to paste both by Ctrl+V and by clicking edit of the command prompt window.

@bhrutledge
Copy link
Contributor

There's already a test1 project on TestPyPI from another user: https://test.pypi.org/project/test1/. That would explain your token being invalid; you don't have permission to upload to that project.

So, try changing your package name to something like ivn-tone-test.

@IVN-tone
Copy link

IVN-tone commented Aug 31, 2021

There's already a test1 project on TestPyPI from another user: https://test.pypi.org/project/test1/. That would explain your token being invalid; you don't have permission to upload to that project.

So, try changing your package name to something like ivn-tone-test.

>python -m twine upload --verbose --repository testpypi dist/*
Uploading distributions to https://test.pypi.org/legacy/
  dist\ivn_tone_test-0.0.1-py3-none-any.whl (2.5 KB)
  dist\ivn-tone-test-0.0.1.tar.gz (2.0 KB)
Enter your username: __token__
Enter your password:
username: __token__
password: <hidden>
Uploading ivn_tone_test-0.0.1-py3-none-any.whl
100%|█████████████████████████████████████| 5.91k/5.91k [00:00<00:00, 9.30kB/s]
Content received from server:
<html>
 <head>
  <title>403 Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.</title>
 </head>
 <body>
  <h1>403 Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.</h1>
  Access was denied to this resource.<br/><br/>
Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.


 </body>
</html>
HTTPError: 403 Forbidden from https://test.pypi.org/legacy/
Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.

still no success((

upd. I also tried in Anaconda prompt (in case the standard Windows command prompt has bug, maybe) - the same error.

@bhrutledge
Copy link
Contributor

I'm stumped. Can you share the source code for your package? IE, put it on GitHub, or zip up the directory and attach it here?

@IVN-tone
Copy link

I'm stumped. Can you share the source code for your package? IE, put it on GitHub, or zip up the directory and attach it here?

here is the link for .zip files:

https://github.com/IVN-tone/packaging_test_ivn-tone/blob/8e8e1a2a1674fbd253aff4fde49f2da9fd4b184e/packaging_tutorial.rar

@bhrutledge
Copy link
Contributor

@IVN-tone I was able to unpack those files, change the package name, and upload to TestPyPI with a token. So, I'm back to thinking that there's something wrong with the token value.

Can you run this command, and paste the output here? This will give you the same password prompt that Twine uses, and should verify whether or not the token value is being pasted properly.

python -c "import getpass; print(len(getpass.getpass()))"

You can also remove the len() call to see the value that you pasted.

@IVN-tone
Copy link

IVN-tone commented Sep 1, 2021

@IVN-tone I was able to unpack those files, change the package name, and upload to TestPyPI with a token. So, I'm back to thinking that there's something wrong with the token value.

Can you run this command, and paste the output here? This will give you the same password prompt that Twine uses, and should verify whether or not the token value is being pasted properly.

python -c "import getpass; print(len(getpass.getpass()))"

You can also remove the len() call to see the value that you pasted.

done, the output is just 1 with len:

python -c "import getpass; print(len(getpass.getpass()))"
Password:
1

and without len the output is the following:

python -c "import getpass; print(getpass.getpass())"
Password:
▬

@bhrutledge
Copy link
Contributor

@IVN-tone Okay! So, there is something wrong with pasting your token; I discovered and documented this behavior in #671 (comment). I think you need to try the workarounds in that comment and #671 (comment) to see if you can get the getpass command to read your token. Once that's working, you should be able to use the same method with Twine.

Aside: I'm a little surprised that using twine upload --verbose showed password: <hidden> instead of password: <empty>; I might look into that a little bit more, to aid in future troubleshooting.

@IVN-tone
Copy link

IVN-tone commented Sep 1, 2021

@IVN-tone Okay! So, there is something wrong with pasting your token; I discovered and documented this behavior in #671 (comment). I think you need to try the workarounds in that comment and #671 (comment) to see if you can get the getpass command to read your token. Once that's working, you should be able to use the same method with Twine.

Aside: I'm a little surprised that using twine upload --verbose showed password: <hidden> instead of password: <empty>; I might look into that a little bit more, to aid in future troubleshooting.

Here it comes:

python -m twine upload --verbose --repository testpypi dist/*
Uploading distributions to https://test.pypi.org/legacy/
  dist\ivn_tone_test-0.0.1-py3-none-any.whl (2.5 KB)
  dist\ivn-tone-test-0.0.1.tar.gz (2.0 KB)
Enter your username: __token__
Enter your password:
username: __token__
password: <hidden>
Uploading ivn_tone_test-0.0.1-py3-none-any.whl
100%|█████████████████████████████████████████| 5.91k/5.91k [00:01<00:00, 4.00kB/s]
Uploading ivn-tone-test-0.0.1.tar.gz
100%|█████████████████████████████████████████| 5.32k/5.32k [00:00<00:00, 6.76kB/s]

View at:
https://test.pypi.org/project/ivn-tone-test/0.0.1/

several facts look suprisingly for me:

  1. I was able to use Ctrl+C\Ctrl+V before I enabled it in properties of command prompt,
  2. it works only if I use the right clcik button (Ctrl+C\Ctrl+V doesn't work).

Thank you so much for your support and being with me in such a strange thriller!:)

@bhrutledge
Copy link
Contributor

@IVN-tone Excellent! I'm glad you were able to get it working.

One note: after looking at the "properties" suggestion:

  • Enabling Properties > Options > Use Ctrl+Shift+C/V as Copy/Paste in the Command Prompt menu

I think enabling this means you can use Ctrl+Shift+V to paste in the command prompt, but still not Ctrl+V. To make it more confusing, this only applies to the command prompt, meaning you'd use Ctrl+C to copy the token from your web browser.

@IVN-tone
Copy link

IVN-tone commented Sep 6, 2021

@IVN-tone Excellent! I'm glad you were able to get it working.

One note: after looking at the "properties" suggestion:

  • Enabling Properties > Options > Use Ctrl+Shift+C/V as Copy/Paste in the Command Prompt menu

I think enabling this means you can use Ctrl+Shift+V to paste in the command prompt, but still not Ctrl+V. To make it more confusing, this only applies to the command prompt, meaning you'd use Ctrl+C to copy the token from your web browser.

Oh, yes, you're right, I forgot about Shift, that's was my fault.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Users asking for help using twine
Projects
None yet
Development

No branches or pull requests

6 participants