skip to Main Content

I am trying to install mapbox in my flutter app:

dependencies:

mapbox_gl: ^0.16.0

and I have been following the guidelines from https://docs.mapbox.com/ios/maps/guides/install/ and https://pub.dev/packages/mapbox_gl#secret-mapbox-access-token to start using it in iOs xcode simulator.

When flutter automatically runs pod install, it comes up with the error

Error output from CocoaPods: ↳ % Total % Received % Xferd
Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed 0 39 0 0
0 0 0 0 –:–:– –:–:– –:–:– 0 curl:
(22) The requested URL returned error: 401

My .netrc is located in ~/ directory.

~/.netrc reads as follows:

machine api.mapbox.com

login mapbox

password sk.xxxxxxx…..xxxxxx

and the secret token does have the Download:read scope

Am I missing something?

I have tried running flutter in macos directly and it works perfectly,I have tried to install mapbox.gl packages from xcode project also and it works, but when I run flutter it tries to install them via pod eitherway and it comes up with the same error.

2

Answers


  1. Had seemingly the same issue locally, deleted and re-created the .netrc file using vi which resolved the issue (previously had been using TextEdit). I followed steps below:

    1. Open Terminal and navigate to the home directory by typing cd ~ and pressing Enter.
    2. Create a new file named .netrc by typing vi .netrc and pressing Enter. This will open an empty file in the terminal.
    3. Press i to enter insert mode and paste the following lines:
        machine api.mapbox.com
        login mapbox
        password <sk.xxxx>
    

    Note: Replace <sk.xxxx> with your Mapbox key.

    1. Press the Esc key to exit insert mode.
    2. Type :w and press Enter to save the file.
    3. Type :q and press Enter to quit from the file.
    4. Re-run the app.
    Login or Signup to reply.
  2. If you still get 401 error after following these steps, you can update your PATH variable for the current session at the command line for .netrc file.

    Try this before pod install or flutter run command.

    export PATH="$PATH:/Users/USERNAME/.netrc"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search