Skip to content

Commit fa26618

Browse files
mfazekasclaude
andcommitted
feat: make Mapbox SDK authentication optional
• Remove mandatory authentication requirement for Mapbox SDK downloads • Update build.gradle files to make MAPBOX_DOWNLOADS_TOKEN optional • Remove .netrc setup from iOS CI workflow • Make gradle.properties setup optional in Android CI workflow • Update Expo plugin to make authentication optional • Update documentation to reflect optional authentication This change aligns with Mapbox's removal of download token requirements as mentioned in: mapbox/mapbox-maps-flutter#775 The authentication is kept optional for backward compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 643a67e commit fa26618

6 files changed

Lines changed: 60 additions & 42 deletions

File tree

.github/workflows/android-actions.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727
MAPBOX_ACCESS_TOKEN:
2828
required: true
2929
MAPBOX_DOWNLOAD_TOKEN:
30-
required: true
30+
required: false
3131
ENV_MAPBOX_ACCESS_TOKEN:
3232
required: false
3333
ENV_MAPBOX_DOWNLOAD_TOKEN:
@@ -60,12 +60,18 @@ jobs:
6060
distribution: 'zulu'
6161
java-version: '17'
6262

63+
# Mapbox download token is no longer required as per Mapbox's removal of authentication requirement
64+
# See: https://github.com/mapbox/mapbox-maps-flutter/issues/775
65+
# Only set if token is provided for backward compatibility
6366
- run: |
6467
mkdir -p ~/.gradle/
65-
echo MAPBOX_DOWNLOADS_TOKEN=$MAPBOX_DOWNLOAD_TOKEN > ~/.gradle/gradle.properties
68+
if [ -n "$MAPBOX_DOWNLOAD_TOKEN" ]; then
69+
echo MAPBOX_DOWNLOADS_TOKEN=$MAPBOX_DOWNLOAD_TOKEN > ~/.gradle/gradle.properties
70+
fi
6671
working-directory: example
6772
env:
6873
MAPBOX_DOWNLOAD_TOKEN: ${{ secrets.MAPBOX_DOWNLOAD_TOKEN || secrets.ENV_MAPBOX_DOWNLOAD_TOKEN }}
74+
if: "${{ secrets.MAPBOX_DOWNLOAD_TOKEN || secrets.ENV_MAPBOX_DOWNLOAD_TOKEN }}"
6975
7076
- run: echo $MAPBOX_ACCESS_TOKEN > ./accesstoken
7177
working-directory: example

.github/workflows/ios-actions.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727
MAPBOX_ACCESS_TOKEN:
2828
required: true
2929
MAPBOX_DOWNLOAD_TOKEN:
30-
required: true
30+
required: false
3131
ENV_MAPBOX_ACCESS_TOKEN:
3232
required: false
3333
ENV_MAPBOX_DOWNLOAD_TOKEN:
@@ -60,15 +60,9 @@ jobs:
6060
env:
6161
MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN || secrets.ENV_MAPBOX_ACCESS_TOKEN }}
6262

63-
- name: Setup .netrc with MAPBOX_DOWNLOAD_TOKEN
64-
run: |
65-
echo 'machine api.mapbox.com' >> ~/.netrc
66-
echo 'login mapbox' >> ~/.netrc
67-
echo "password $MAPBOX_DOWNLOAD_TOKEN" >> ~/.netrc
68-
chmod 0600 ~/.netrc
69-
if: "${{ env.MAPBOX_DOWNLOAD_TOKEN != '' }}"
70-
env:
71-
MAPBOX_DOWNLOAD_TOKEN: ${{ secrets.MAPBOX_DOWNLOAD_TOKEN || secrets.ENV_MAPBOX_DOWNLOAD_TOKEN }}
63+
# Mapbox download token is no longer required as per Mapbox's removal of authentication requirement
64+
# See: https://github.com/mapbox/mapbox-maps-flutter/issues/775
65+
# .netrc setup is no longer needed for iOS builds
7266

7367
- name: Setup node ${{ inputs.NVMRC }}
7468
uses: actions/setup-node@v3.5.1

android/install.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,20 @@ allprojects {
2020
// ...other repos
2121
maven {
2222
url 'https://api.mapbox.com/downloads/v2/releases/maven'
23-
authentication {
24-
basic(BasicAuthentication)
25-
}
26-
credentials {
27-
// Do not change the username below.
28-
// This should always be `mapbox` (not your username).
29-
username = 'mapbox'
30-
// Use the secret token you stored in gradle.properties as the password
31-
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
23+
// Authentication is no longer required as per Mapbox's removal of download token requirement
24+
// See: https://github.com/mapbox/mapbox-maps-flutter/issues/775
25+
// Keeping this as optional for backward compatibility
26+
if (project.properties['MAPBOX_DOWNLOADS_TOKEN']) {
27+
authentication {
28+
basic(BasicAuthentication)
29+
}
30+
credentials {
31+
// Do not change the username below.
32+
// This should always be `mapbox` (not your username).
33+
username = 'mapbox'
34+
// Use the secret token you stored in gradle.properties as the password
35+
password = project.properties['MAPBOX_DOWNLOADS_TOKEN']
36+
}
3237
}
3338
}
3439
// ...even more repos?

example/android/build.gradle

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,20 @@ allprojects {
5454

5555
maven {
5656
url 'https://api.mapbox.com/downloads/v2/releases/maven'
57-
authentication {
58-
basic(BasicAuthentication)
59-
}
60-
credentials {
61-
// Do not change the username below.
62-
// This should always be `mapbox` (not your username).
63-
username = 'mapbox'
64-
// Use the secret token you stored in gradle.properties as the password
65-
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
57+
// Authentication is no longer required as per Mapbox's removal of download token requirement
58+
// See: https://github.com/mapbox/mapbox-maps-flutter/issues/775
59+
// Keeping this as optional for backward compatibility
60+
if (project.properties['MAPBOX_DOWNLOADS_TOKEN']) {
61+
authentication {
62+
basic(BasicAuthentication)
63+
}
64+
credentials {
65+
// Do not change the username below.
66+
// This should always be `mapbox` (not your username).
67+
username = 'mapbox'
68+
// Use the secret token you stored in gradle.properties as the password
69+
password = project.properties['MAPBOX_DOWNLOADS_TOKEN']
70+
}
6671
}
6772
}
6873
}

plugin/build/withMapbox.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,16 @@ allprojects {
211211
repositories {
212212
maven {
213213
url 'https://api.mapbox.com/downloads/v2/releases/maven'
214-
authentication { basic(BasicAuthentication) }
215-
credentials {
216-
username = 'mapbox'
217-
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: System.getenv('RNMAPBOX_MAPS_DOWNLOAD_TOKEN') ?: {
218-
throw new GradleException('❌ RNMapbox Maps Error: Mapbox download token is required.\\nSet RNMAPBOX_MAPS_DOWNLOAD_TOKEN environment variable:\\n export RNMAPBOX_MAPS_DOWNLOAD_TOKEN="sk.ey...qg"\\n npx expo prebuild\\n\\nOr use deprecated config:\\n RNMapboxMapsDownloadToken in app.json plugin config')
219-
}()
214+
// Authentication is no longer required as per Mapbox's removal of download token requirement
215+
// See: https://github.com/mapbox/mapbox-maps-flutter/issues/775
216+
// Keeping this as optional for backward compatibility
217+
def token = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: System.getenv('RNMAPBOX_MAPS_DOWNLOAD_TOKEN')
218+
if (token) {
219+
authentication { basic(BasicAuthentication) }
220+
credentials {
221+
username = 'mapbox'
222+
password = token
223+
}
220224
}
221225
}
222226
}

plugin/src/withMapbox.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,16 @@ allprojects {
331331
repositories {
332332
maven {
333333
url 'https://api.mapbox.com/downloads/v2/releases/maven'
334-
authentication { basic(BasicAuthentication) }
335-
credentials {
336-
username = 'mapbox'
337-
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: System.getenv('RNMAPBOX_MAPS_DOWNLOAD_TOKEN') ?: {
338-
throw new GradleException('❌ RNMapbox Maps Error: Mapbox download token is required.\\nSet RNMAPBOX_MAPS_DOWNLOAD_TOKEN environment variable:\\n export RNMAPBOX_MAPS_DOWNLOAD_TOKEN="sk.ey...qg"\\n npx expo prebuild\\n\\nOr use deprecated config:\\n RNMapboxMapsDownloadToken in app.json plugin config')
339-
}()
334+
// Authentication is no longer required as per Mapbox's removal of download token requirement
335+
// See: https://github.com/mapbox/mapbox-maps-flutter/issues/775
336+
// Keeping this as optional for backward compatibility
337+
def token = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: System.getenv('RNMAPBOX_MAPS_DOWNLOAD_TOKEN')
338+
if (token) {
339+
authentication { basic(BasicAuthentication) }
340+
credentials {
341+
username = 'mapbox'
342+
password = token
343+
}
340344
}
341345
}
342346
}

0 commit comments

Comments
 (0)