Reputation: 3113
I have uploaded packages to pub.dartlang.org under two different accounts (one of them work-related, the other personal).
The pub
command line tool doesn't have any option to select with which account to publish, so once I log on with the tool, and try to upload a package that belongs to the other account, I see:
$ pub publish
UnauthorizedAccess: Unauthorized user: [email protected] is not allowed to upload versions to package xyz..
How do I publish with a specific account? Failing that, how do I log out the pub
tool in order to log on again under a different account?
Upvotes: 1
Views: 141
Reputation: 10925
If you want to temporarily publish with different credentials you can use a command like:
PUB_CACHE=~/.other_credentials_cache pub publish
This will create a entirely separate "profile" which is used whenever running any pub
command with the PUB_CACHE
environment variable pointing to a directory other than ~/.pub_cache
. If you were to pub get
with this cache you'd get entirely separate package downloaded.
With this approach you can toggle between credentials by specifying or not specifying the different cache directory. You'll need to authenticate the first time you use the new directory.
Upvotes: 1
Reputation: 3113
There is currently no way in the command line pub
tool to upload under different credentials (although there is a proposal).
If you have a fairly recent version of pub
, you can log out with:
$ pub logout
Then try pub publish
again. The tool will ask you for new credentials.
The pub logout
command is an addition from January 2019. If pub
tells you this command doesn't exist, you'll have to manually remove the credentials file.
$ rm ~/.pub-cache/credentials.json
Upvotes: 1