react-nativeexpotokenmapboxeas

Expo EAS build fails due to Mapbox token missing


My EAS build fails during the Install pods with the message at the very bottom.

The https link in the error message is showing the following:

{"message":"Not Authorized - No Token","url":"[GET] /downloads/v2/mapbox-common/releases/ios/packages/23.9.2/MapboxCommon.zip","auth":"<no access token>","ua":"Amazon CloudFront"}

This is even though there is already a public key access token generated on the mapbox.com website and set in the following manner in the code right after Mapbox import:

import Mapbox from '@rnmapbox/maps';
Mapbox.setAccessToken( 'pk.eyJ1Ijoi...mapbox public key: a string starting with pk.' );

I also have the following in the app.config.js file:

            [
                '@rnmapbox/maps',
                {
                    RNMapboxMapsImpl: 'mapbox',
                    RNMapboxMapsDownloadToken: 'pk.eyJ1Ijoi...mapbox public key: a string starting with pk',
                },
            ] 
    ]

The EAS build error message:

[!] Error installing MapboxCommon
[!] /usr/bin/curl -u mapbox:************************************************************************************** -f -L -o /var/folders/ff/bn0lvz090nnd0cqhqsthp7v00000gn/T/d20240608-1423-1e8p20i/file.zip https://api.mapbox.com/downloads/v2/mapbox-common/releases/ios/packages/23.9.2/MapboxCommon.zip --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.14.3 cocoapods-downloader/2.1'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   275    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 403
[!] [Codegen] warn: using experimental new codegen integration
[!] `<PBXResourcesBuildPhase UUID=`13B07F8E1A680F5B00A75B9A`>` attempted to initialize an object with an unknown UUID. `E1955A98FC9244529D81109D` for attribute: `files`. This can be the result of a merge and the unknown UUID is being discarded.
Error: Unknown error. See logs of the Install pods build phase for more information.```. 


Solution

  • So I was able to figure out a solution. Although I am not sure these are all the right steps needed in your case, this resolved the above problem and the EAS build was successful.

    I created a secret token (not to be mistaken with public token) in my Mapbox account. This secret token should have DOWNLAODS:READ scope selected as shown in the screenshot.

    Note that this secret key is placed in the app.config.js file. The public key is still needed as before to be able to load the map. So the corresponding line in app.config.js file would change to something as

    RNMapboxMapsDownloadToken: 'sk.eyJ1Ijoi...mapbox secret key: a string starting with sk',
    

    enter image description here