-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
QuestionFurther information is requestedFurther information is requested
Description
How can we help?
This code is getting error 403. I believe key
and appId
was not wrong because I used them on https://documentation.onesignal.com/reference/update-user?playground=open#parameter-app-id and API was called successfully.
Code
import * as OneSignal from '@onesignal/node-onesignal';
const appId = 'app id here';
const restApiKey = 'key here';
const organizationApiKey = 'key here';
export const oneSignalUpdateUserProperty = async (params: {
userId: string;
propertyName: string;
propertyValue: any;
}) => {
const configuration = OneSignal.createConfiguration({
restApiKey,
organizationApiKey,
});
const client = new OneSignal.DefaultApi(configuration);
try {
return client.getUser(appId, 'external_id', params.userId);
} catch (err) {
console.error('Error getting user:', err);
return false;
}
};
Error details:
Error: HTTP-Code: 403
Message: Unknown API Status Code!
Body: {}
Headers: {"access-control-allow-headers":"OneSignal-Subscription-Id","alt-svc":"h3=\":443\"; ma=86400","cf-cache-status":"DYNAMIC","cf-ray":"966bc0633bd48149-HKG","connection":"keep-alive","content-encoding":"br","content-type":"text/plain","date":"Tue, 29 Jul 2025 09:57:20 GMT","server":"cloudflare","set-cookie":"__cf_bm=axiu.zu_89lCdHW.xx-1753783040-1.0.1.1-PxDxQ068ruWy_.Lh9Q7jHRuwcQmsjbD.xx.5Gz7JwJhsJ7u6q5qepM8EXFrq.xx; path=/; expires=Tue, 29-Jul-25 10:27:20 GMT; domain=.onesignal.com; HttpOnly; Secure; SameSite=None","strict-transport-security":"max-age=15552000; includeSubDomains","transfer-encoding":"chunked","via":"1.1 google"}
This working fine
const apps = await client.getApps();
console.log(apps);
Please help!
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
QuestionFurther information is requestedFurther information is requested