[question] HTTP 401 error when following the examples and guides
See original GitHub issueI’m fairly certain I’m following the examples correctly, but I get 401 errors so tiles don’t load.
This is my code:
// import OmvTileDecoderService inside a web Worker with vanilla JS, thanks to
// the JSPM ES Module CDN (https://jspm.io).
const workerCode = `
async function main() {
const { OmvTileDecoderService } = (
await import('https://dev.jspm.io/@here/harp-omv-datasource/index-worker')
).default
OmvTileDecoderService.start()
}
main()
`;
const blob = new Blob([workerCode], { type: "application/javascript" });
// const worker = new Worker(URL.createObjectURL(blob), { type: "module" });
const canvas = document.getElementById("harpCanvas");
const map = new MapView({
canvas,
// theme:
// "https://unpkg.com/@here/harp-map-theme@latest/resources/berlin_tilezen_night_reduced.json",
theme:
"https://unpkg.com/@here/harp-map-theme@0.13.0/resources/berlin_tilezen_base.json",
decoderUrl: URL.createObjectURL(blob),
//For tile cache optimization:
maxVisibleDataSourceTiles: 40,
tileCacheSize: 100
});
map.setCameraGeolocationAndZoom(
new GeoCoordinates(1.278676, 103.850216),
16
);
const mapControls = new MapControls(map);
const ui = new MapControlsUI(mapControls);
canvas.parentElement.appendChild(ui.domElement);
mapControls.maxPitchAngle = 90;
// mapControls.setRotation(6.3, 50);
// mapControls.camera.rotation
map.resize(window.innerWidth, window.innerHeight);
window.onresize = () => map.resize(window.innerWidth, window.innerHeight);
const omvDataSource = new OmvDataSource({
baseUrl: "https://xyz.api.here.com/tiles/herebase.02",
apiFormat: APIFormat.XYZOMV,
styleSetName: "tilezen",
authenticationCode: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
});
map.addDataSource(omvDataSource);
where XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
is my API key that I created by first making a new JavaScript App ID, then for that app making an API key and pasting that key in my Harp example.
Any ideas why?
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
How to Quickly Fix the 401 Unauthorized Error (5 Methods)
The 401 (Unauthorized) status code indicates that the request has not been applied because it lacks valid authentication credentials for the ...
Read more >401 Error: 5 Ways to Troubleshoot and Fix It - Hostinger
The 401 Unauthorized error is triggered by unauthenticated requests made to a WordPress web server. Learn how to identify and fix the issue....
Read more >A Useful Guide to Diagnosing and Solving the 401 Error
It can be extremely frustrating to encounter a 401 error, whether it's your or not. Here's a useful guide to getting around the...
Read more >401 Unauthorized Error: What It Is and How to Fix It
The 401 Unauthorized Error is an HTTP response status code indicating that the client could not authenticate a request.
Read more >401 Unauthorized - HTTP - MDN Web Docs
The HyperText Transfer Protocol (HTTP) 401 Unauthorized response status code indicates that the client request has not been completed ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
method: harp.AuthenticationMethod.QueryString
@trusktr , thanks again for looking into this.
I notice that we can simplify the interface, why should you need to specify the
authenticationMethod
, when the format could decide… or at least the format supplies a default authentication method, which could be this apikey, seegetDefaultAuthMethod
onOmvRestClient
I created an issue so that we can simplify this for others: https://github.com/heremaps/harp.gl/issues/1390