Hey there,
I'm attempting to build a simple Node/Express server via TypeScript, and I can't get a simple request to the REST API to work. I've checked my JWToken (after decoding it) and it matches what Apple is requests, and what other have shown to work in their node servers.
I created a separate key to use for this node app, in case it was some conflict with my key for my iOS app.
Any guesses as to why?
Here's the code in question with private info removed:
var jwtToken = jwt.sign({ subject: 'my.company' },
privateKey,
{
jwtid: '#########.my.company',
issuer: 'myTeamID',
expiresIn: '1hr',
keyid: '#########',
algorithm: 'ES256',
header: { alg: 'ES256', id: 'myTeamID.my.company' } as JwtHeader,
});
export async function requestWeather() {
console.log('Token:', jwtToken)
const authHeader = {
headers: { Authorization: `Bearer ${jwtToken}`}
}
const url = "https://weatherkit.apple.com/api/v1/weather/en/37.323/122.032?dataSets=currentWeather";
const request = await axios.get(url, authHeader)
console.log(request)
}
2
0
1.5k