mapbox-navigation-ios
mapbox-navigation-ios copied to clipboard
Offline Routing tiles 402 error
Mapbox Navigation SDK version
2.2.1
Steps to reproduce
When calling Directions.shared.downloadTiles we are getting a 402 response.
`▿ Optional<NSURLResponse>
- some : <NSHTTPURLResponse: 0x280dd27c0> { URL: https://api.mapbox.com/route-tiles/v1/-118.46003707025038,33.56680755615234%3B-117.97809295654301,34.33335820197513?version=2022_07_09-03_00_00&access_token=*** } { Status Code: 402, Headers { "Access-Control-Allow-Origin" = ( "*" ); Connection = ( "keep-alive" ); "Content-Length" = ( 223 ); "Content-Type" = ( "application/json; charset=utf-8" ); Date = ( "Tue, 12 Jul 2022 20:47:39 GMT" ); Vary = ( "Accept-Encoding" ); Via = ( "1.1 1c5a7e2dbc29e2ce87f40dbbc168a96c.cloudfront.net (CloudFront)" ); "X-Amz-Cf-Id" = ( "Cmhvo61chMXrkCTpqDVGg4h4Y1qUY3Y8o8kkl_7xg1sj5ZOysUwl0A==" ); "X-Amz-Cf-Pop" = ( "LAX50-P2" ); "X-Cache" = ( "Error from cloudfront" ); "X-Content-Type-Options" = ( nosniff ); "X-Rate-Limit-Interval" = ( 60 ); "X-Rate-Limit-Limit" = ( 1000 ); "X-Rate-Limit-Reset" = ( 1657658919 ); "x-mapbox-request-id" = ( "Cmhvo61chMXrkCTpqDVGg4h4Y1qUY3Y8o8kkl_7xg1sj5ZOysUwl0A==" ); } }`
Defined scopes for our token are as follows:
Expected behavior
When calling Directions.shared.downloadTiles we are expecting a 200 response and should be able to call Directions api while offline.
Actual behavior
When calling Directions.shared.downloadTiles we are getting a 402 response and we are not able to call Directions api while offline to fetch a route.
Is this a one-time issue or a repeatable issue?
repeatable
@RRuais, thanks for sharing additional information. I've just built your project and was able to download tiles successfully with similar access token scopes. Will have to do further debugging to see what might be wrong. Will update this ticket when I have more information.
@RRuais, sorry for a delayed reply. Preferred way of implementing offline functionality for maps and navigation when using Navigation SDK v2.x is using TileStore APIs. We do not have a Navigation SDK guide for that yet, but you can use an Offline API reference provided by Maps SDK at this point.
All stated above is related to non active navigation use case. When it comes to active navigation using NavigationViewController APIs please look at this guide.
The reason you're getting 402 HTTP status code while using Mapbox Directions APIs for offline routing is that it connects to a different endpoint, and to use it additional permissions must be requested on case by case basis.