Code Monkey home page Code Monkey logo

Comments (2)

blakmatrix avatar blakmatrix commented on August 17, 2024

Hello @frec-hansen ,

Thank you for reaching out with your issue regarding the 401: Not Authorized error in the node-zendesk library. After reviewing the details, it seems the problem stems from the way OAuth tokens are being handled, i.e. not a bug--you need to provision an OAuth token.

To help you navigate this, I've updated the library and added a detailed example script. Here are the key updates and some important guidelines:

  1. New OAuthClients Class: I've introduced a new OAuthClients class in the library. This class offers functionalities for managing OAuth clients, including listing, creating, updating, and deleting OAuth clients, and generating client secrets.

  2. Detailed Example Script: An example script has been updated with comprehensive JSDoc comments. It demonstrates how to create a read-only OAuth token, which involves retrieving your OAuth client's numeric ID using its unique identifier. You can find this script @ https://github.com/blakmatrix/node-zendesk/blob/master/examples/create-oauth-token.js.

  3. Provisioning an OAuth Token: It's important to note that for using the library, you need to provision an OAuth token specifically for this purpose. The secret token you mentioned is used in a different context with a back and forth OAuth Client. The example script will guide you through creating an OAuth token with the necessary scopes. Initially, you'll need your username/password or username/API token (and appropriat admin access of course) to generate an OAuth token in this method.

  4. Setting Appropriate Permissions: The example demonstrates creating a token with read-only access for users and tickets. Depending on your needs, you can adjust these scopes to grant more permissions. Please refer to the Zendesk documentation on Creating and using OAuth tokens with the API for more detailed guidance or alternitive methods for provisioning(i.e. curl).

  5. Using the OAuth Token for Authentication: Once you've generated the OAuth token, you can use it to authenticate in the client. Keep in mind the permissions (scopes) assigned to the token will dictate what actions you can perform through the API.

I hope these updates and instructions will help you resolve the authorization issues. Please pull the latest version of the node-zendesk library to access these new features and improvements. If you have any further questions or face additional issues, feel free to reach out.

Best regards,

Farrin

from node-zendesk.

frec-hansen avatar frec-hansen commented on August 17, 2024

Thanks for the detailed reply and updated example. I will revert back and use the username/password auth since it is a lot easier. I just want minimum setup to use it. BTW. I want to point out that some of the documents probably also need to be updated. When I was using users.createOrUpdate according to doc like this:

zendeskClient.users.createOrUpdate({ name:"test", email:"[email protected]" });

I got a 400 response.
Turns out the attributes needs to be wrapped in user object:

zendeskClient.users.createOrUpdate({ user: { name:"test", email:"[email protected]" }  });

from node-zendesk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.