Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question]: Having problems making a simple fetchUser API call + broken links in docs #68

Closed
1 task done
kpturner opened this issue Aug 29, 2023 · 1 comment
Closed
1 task done

Comments

@kpturner
Copy link

kpturner commented Aug 29, 2023

How can we help?

I cannot seem to make a simple fetchUser API call work. The documentation tells me to do it like so:

const configuration = OneSignal.createConfiguration({
  userKey: process.env.ONESIGNAL_USER_KEY
  appKey: process.env.ONESIGNAL_APP_ID,
})

const client = new OneSignal.DefaultApi(configuration)

client
  .fetchUser('my_app_id', 'external_id', 'foo')
  .then((data) => {
    logger.debug(data, 'API called successfully. Returned data')
  })
  .catch((error) => logger.error(error, 'Error calling OneSignal'))

It is not totally clear what the userKey and appKey should be so I have assumed that this is the application key and REST API key from the "Keys & IDs" page on the OneSignal Dashboard.

However, when I try that I just get

Error: HTTP-Code: 404
    Message: Unknown API Status Code!
    Body: {}

I saw other issues logged where people have set the configuration like this:

const appKeyProvider = {
  getToken() {
    return process.env.ONESIGNAL_REST_API_KEY as string
  },
}
const configuration = OneSignal.createConfiguration({
  authMethods: {
    app_key: {
      tokenProvider: appKeyProvider,
    },
  },
})

But that just gives me the same error.

I then found this:
https://github.com/OneSignal/onesignal-node-api/blob/main/DefaultApi.md#fetchUser

But that does not work because fetchUser expects 3 (or 4) parameter, not 1.

What am I doing wrong?

As an aside, this https://github.com/OneSignal/onesignal-node-api has broken or misleading links.

The link here does not take you to anywhere useful
image

And this link is broken
image

Code of Conduct

  • I agree to follow this project's Code of Conduct
@kpturner
Copy link
Author

kpturner commented Aug 29, 2023

Well I finally got it working by providing no configuration at all

const configuration = OneSignal.createConfiguration({})
const client = new OneSignal.DefaultApi(configuration)
client
  .fetchUser(process.env.ONESIGNAL_APP_ID as string, 'external_id', 'foo')
  .then((data) => {
    logger.debug(data, 'API called successfully. Returned data')
  })
  .catch((error) => logger.error(error, 'Error calling OneSignal'))

@kpturner kpturner changed the title [question]: Having problems making a simple fetchUser API call [question]: Having problems making a simple fetchUser API call + broken links in docs Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants