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

apiKeyAuth returning "unauthorised" #329

Open
poppet-uk opened this issue Nov 14, 2022 · 3 comments
Open

apiKeyAuth returning "unauthorised" #329

poppet-uk opened this issue Nov 14, 2022 · 3 comments

Comments

@poppet-uk
Copy link

Please use the following template to submit your issue. Following this template will allow us to quickly investigate and help you with your issue. Please be aware that issues which do not conform to this template may be closed.

For feature requests please contact us at team@intercom.io

Version info

  • intercom-node version: 3.1.5
  • Node version: 15.0.9

Expected behavior

Screenshot 2022-11-14 at 23 48 05
Creating a new instance of the intercom Client using the "apiKeyAuth" should authenticate. "tokenAuth" works fine.

Actual behavior

Any request I make using the "apiKeyAuth" returns "unauthorized".

Steps to reproduce

  1. create a new Client providing the apiKeyAuth params.
  2. try to make a request to intercom

Logs

Error: Unauthorized
    at new BadResponseError (/Users/drakemacbook2/Documents/Programming/cc/node_modules/lib/errors/badResponse.error.ts:10:9)
    at Client.checkOnErrorInResponse (/Users/drakemacbook2/Documents/Programming/cc/node_modules/lib/client.ts:258:16)
    at Client.<anonymous> (/Users/drakemacbook2/Documents/Programming/cc/node_modules/lib/client.ts:204:24)
    at step (/Users/drakemacbook2/Documents/Programming/cc/node_modules/intercom-client/dist/client.js:52:23)
    at Object.throw (/Users/drakemacbook2/Documents/Programming/cc/node_modules/intercom-client/dist/client.js:33:53)
    at rejected (/Users/drakemacbook2/Documents/Programming/cc/node_modules/intercom-client/dist/client.js:25:65)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
@SeanHealy33
Copy link
Contributor

Hi @poppet-uk

I'm a little unsure of the issue here. The documented way of adding an api key is const client = new Client({ tokenAuth: { token: 'my_token' } }); as documented in the readme.

Could you let me know a little bit more about your use case

@poppet-uk
Copy link
Author

Certainly,

So in the client.d.ts file, the types indicate that I can authenticate using an apiKey and appId.

Screenshot 2022-12-15 at 22 25 50

However trying to do so returns the aforementioned error.

Our usecase is that we have an intercom for production and an intercom app for testing. In order to work with exclusively our testing app, we can't simply authenticate with the authToken as I believe that's linked to our production env.

@SeanHealy33
Copy link
Contributor

SeanHealy33 commented Dec 16, 2022

So I did some digging on this.

appAPIKey in this context refers to a legacy token system we used before the Developer Hub was created (circa 2018).

If you created your app in the dev hub and have a auth key from there then it uses TokenAuth exclusively. The api is returning
unauthorized since your key does not exist on that workspace in the legacy auth system we have.

I'll keep this issue open though since we clearly need to document the different schemes of auth that the SDK supports and how they work.

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