mapbox / mapbox-vision-android-teaser

Other
29 stars 13 forks source link

401 Response could not get mapbox-android-vision-0.13.0.pom #226

Closed kalkun closed 3 years ago

kalkun commented 3 years ago

Getting 401 response error when trying to build app:

Could not GET 'https://api.mapbox.com/downloads/v1/vision/android/maven/com/mapbox/vision/mapbox-android-vision/0.13.0/mapbox-android-vision-0.13.0.pom'. Received status code 401 from server: Unauthorized
Disable Gradle 'offline mode' and sync project

I have tried on the dev and on master branch - with no changes of mine.

I have also tried both with a token with scope vision:download and one with all scopes - both approaches received the same message.

E.g., listing tokens through api call shows both:

$ curl -so - "https://api.mapbox.com/tokens/v2/<user>?access_token=<access_token>" | python -m json.tool                                   
[
    {
        "client": "api",
        "note": "test-vision-sdk",
        "usage": "sk",
        "id": "<id>",
        "default": false,
        "scopes": [
            "vision:download"
        ],
        "created": "2021-04-28T07:13:01.164Z",
        "modified": "2021-04-28T07:13:01.164Z"
    },
    {
        "client": "api",
        "note": "vision-sdk-test",
        "usage": "sk",
        "id": "<id>",
        "default": false,
        "scopes": [
            "vision:download",
            "vision:read",
            "downloads:read",
            "styles:tiles",
            "styles:read",
            "fonts:read",
            "datasets:read",
            "user:read",
            "uploads:write",
            "styles:list",
            "datasets:list",
            "tilesets:write",
            "offline:read",
            "navigation:download",
            "tilesets:read",
            "tokens:write",
            "styles:write",
            "uploads:list",
            "map:write",
            "map:read",
            "uploads:read",
            "tokens:read",
            "tilesets:list",
            "scopes:list",
            "user:write",
            "fonts:list",
            "styles:download",
            "datasets:write",
            "offline:write"
        ],
        "created": "2021-04-27T17:37:09.592Z",
        "modified": "2021-04-27T20:07:34.730Z"
    },
    {
        "client": "api",
        "note": "Default Public Token",
        "usage": "pk",
        "id": "<id>",
        "default": true,
        "scopes": [
            "styles:tiles",
            "styles:read",
            "fonts:read",
            "datasets:read",
            "vision:read"
        ],
        "created": "2016-11-29T13:52:56.948Z",
        "modified": "2016-11-29T13:52:56.948Z",
        "token": "<token>"
    }
]

In the build.gradle file I have tried throwing an exception that shows mapboxMavenUser=mapbox and mapboxMavenToken=<my key>:

maven {
    credentials {
        username project.properties['mapboxMavenUser'] ?: ""
        password project.properties['mapboxMavenToken'] ?: ""
    }
    authentication {
        basic(BasicAuthentication)
    }

    // This shows that credentials are set:
    throw new Exception("Credentials ${project.properties['mapboxMavenUser']} ${project.properties['mapboxMavenToken']}")

    url 'https://api.mapbox.com/downloads/v1/vision/android/maven'
}
kalkun commented 3 years ago

For anyone else running into this problem, then I could solve it by downloading the *aar files instead.

What worked for me was to follow the solution here:

yunikkk commented 3 years ago

Hi @kalkun, good to hear that workaround with direct aar download works for you, though seems maven is still broken. Reopen to investigate.

yunikkk commented 3 years ago

We've indeed discovered that our custom maven repo has the issue an is not working at the moment. Working on the fix.

kalkun commented 3 years ago

@yunikkk On a perhaps related note: it seems that when I add Vision SDK through aar files, then I dont get a Mapbox Telemetry dependency. Which seems to be needed in order to call VisionMangager.init(). I assume I would have had this if installed through the Maven repository, is this a correct assumption?

For reference I see a message like this:

    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/mapbox/android/telemetry/AttachmentListener;
        at com.mapbox.vision.VisionManager.init(Unknown Source:0)
yunikkk commented 3 years ago

@yunikkk On a perhaps related note: it seems that when I add Vision SDK through aar files, then I dont get a Mapbox Telemetry dependency. Which seems to be needed in order to call VisionMangager.init(). I assume I would have had this if installed through the Maven repository, is this a correct assumption?

For reference I see a message like this:

    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/mapbox/android/telemetry/AttachmentListener;
        at com.mapbox.vision.VisionManager.init(Unknown Source:0)

Right, if you add dependencies via gradle/maven - vision dependencies are automatically added to the project, while aars does not allow to add transitive dependencies. You'll need to them manually as stated at https://vision.mapbox.com/install/,

dependencies {
implementation("com.mapbox.mapboxsdk:mapbox-android-accounts:0.3.0")
implementation("com.mapbox.mapboxsdk:mapbox-android-telemetry:4.7.3")
}
yunikkk commented 3 years ago

@kalkun we've rolled out the fix, https://github.com/mapbox/mapbox-vision-android-teaser/pull/227. This will require a new token though, so if you still need the fix please generate the new one.

yunikkk commented 3 years ago

The docs have been updated, new installation section is at https://docs.mapbox.com/android/vision/guides/