【发布时间】:2021-08-31 15:16:34
【问题描述】:
在 react native 中使用 mapbox 时出现授权错误
https://api.mapbox.com/downloads/v1/navigation/android/maven/com/mapbox/navigation/ui/1.5.0/ui-1.5.0.pom'。从服务器收到状态码 401:未授权
我正在使用这个包(https://www.npmjs.com/package/@homee/react-native-mapbox-navigation)
根据包文档我也在做同样的事情。
我的 build.gradle 文件是
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
}
repositories {
google()
jcenter()
maven {
url 'https://api.mapbox.com/downloads/v1/navigation/android/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
username = "mapbox"
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://mapbox.bintray.com/mapbox' }
maven { url 'https://www.jitpack.io' }
maven {
url 'https://api.mapbox.com/downloads/v1/navigation/android/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
username = "mapbox"
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}
}
}
【问题讨论】:
-
您的凭据是否正确?
标签: react-native mapbox