Hi, I'm building an app to build and update a wallet pass.
I want to send a push notification to the Wallet app to update the pass, but I got the following error.
:status: 403
apns-id: 3EDEDFEA-C8F1-215A-D9F3-2FA7D6C5AF0C
{reason: MissingProviderToken}
I am using the certificate and authentication header like this.
var storage = admin.storage().bucket()
var signerCert = (await getRawBody(storage.file('signerCert.pem').createReadStream())).toString();
var signerKey = (await getRawBody(storage.file('signerKey.pem').createReadStream())).toString();
// 方法1(クライアント立てる)
const client = http2.connect(url);
client.on('socketError', (err) => console.error('ソケットエラー!',err));
client.on('error', (err) => console.error('エラー!',err));
var header = {
'Authrorization': 'Bearer '+pushToken
}
const req = client.request({
':method': 'POST',
':path': path,
'cert': signerCert,
'key': signerKey,
'passphrase': '',
'headers': JSON.stringify(header),
});
req.on('response', (headers, flags) => {
for (const name in headers) {
console.log(`${name}: ${headers[name]}`);
}
});
req.setEncoding('utf8');
let data = '';
req.on('data', (chunk) => { data += chunk; });
req.on('end', () => {
console.log(`\n${data}`);
client.destroy();
});
req.end();
Language is Typescript. The code sits in Cloud Functions.
Is there something wrong with the code?