401: Unauthorized

One of my package dependency is hosted on OnePub.

When running dart pub get I'm seeing a 401: Unauthorized error.

This means that you are not logged in or not logged into the correct organisation.

The first thing to do is to ensure you are logged into the OnePub on the CLI:

onepub login

Run dart pub get again and hopefully that solves your problem.

If that didn't fix it then read on.

multiple organisations

You may be a member of multiple OnePub organisations.

If you joined OnePub by accepting an invitation then you will automatically be a member of two OnePub organisations.

When you accept a OnePub invitation we automatically create your own personal OnePub organisation as well as joining you to the organisation you were invited to.

This could mean that when you logged into OnePub from the CLI that you logged into the wrong organisation.

You can check which organisation you are logged into by running:

onepub doctor

You should see the Organisation name near the bottom of the output.

switching organisations

To switch between organisations at the CLI run:

onepub login

When you click on the url displayed by the login command you will be prompted with a droplist showing the organisations that you belong to.

Select the organisation that want to login to.


dart pub get

Now your problem should be solved.

No? Then you can reach out for help via the OnePub discussions forums

Last updated