Post

Replies

Boosts

Views

Activity

Apple Maps Server API Unauthorized Error
I'm trying to use the new Apple Maps Server API. As far as I can tell I have set up the token correctly, but my web request is still returning 401 unauthorized. The following is my code in TypeScript: import * as jwt from 'jsonwebtoken'; const JWT_SECRET = "-----BEGIN PRIVATE KEY-----\n" + "MIGTAgEAMBMGBy..............................\n" + "..............................................................\n" + "..............................................................\n" + "-----END PRIVATE KEY-----"; const header = { alg: "ES256", kid: "26DYPK65ZK", typ: "jwt" } // Example payload data const payload = { "iss": "7F3PBYWYMS", "iat": Date.now(), "exp": Date.now() + (1000 * 30 * 60), }; export async function getRestaurants() { let token = jwt.sign(payload, JWT_SECRET, { algorithm: 'ES256', header: header}); const response = await fetch('https://maps-api.apple.com/v1/token (https://maps-api.apple.com/v1/token)', { method: 'GET', headers: { 'Authorization': "Bearer " + token }, }); console.log(response); } What am I doing incorrectly here?
6
0
202
Oct ’24