'Insufficient permissions to the resource in https://pub.dartlang.org package repository

I got this error when I delete flutter-sdk and replace new flutter-sdk

Insufficient permissions to the resource in https://pub.dartlang.org package repository. You can modify credential using:
    pub token add https://pub.dartlang.org
Running "flutter pub get" in flutter_tools...                           
pub get failed (65;     pub token add https://pub.dartlang.org)

flutter version :

Flutter 2.8.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision cf44000065 (6 days ago) • 2021-12-08 14:06:50 -0800
Engine • revision 40a99c5951
Tools • Dart 2.15.0


Solution 1:[1]

First delete credentials:

rm ~/.pub-cache/credentials.json

After you try:

flutter upgrade
flutter pub cache repair

Solution 2:[2]

I had the same issue. You need to use a VPN.

Solution 3:[3]

I just restart my system and then try to do "flutter pub get" and it works :|, And also I change my VPN.

Solution 4:[4]

To solve this problem, make sure that follow these steps:

  1. run flutter clean
  2. make sure that you have reliable internet connection and if you are using VPN, make sure it has reliable connection
  3. run your project again.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 EliaTolin
Solution 2 Pedram Mohammad Ali pour
Solution 3
Solution 4 DharmanBot