Skip to content

Commit

Permalink
Support useOAuth property while maintaining backward compatibility
Browse files Browse the repository at this point in the history
This commit reintroduces backward compatibility for the oauth property while transitioning to the new useOAuth property for indicating OAuth authentication. The isOAuth method has been updated to check both properties, prioritizing useOAuth if both are set. Additionally, the types have been updated to reflect the new useOAuth property, providing a clear path for developers to adopt the new property while ensuring existing code continues to function as expected.
  • Loading branch information
blakmatrix committed Oct 27, 2023
1 parent d3ed43b commit 15910e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/clients/authorization-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ class AuthorizationHandler {
* @returns {boolean} True if OAuth is the chosen method; false otherwise.
*/
isOAuth() {
return this.options.get('useOAuth');
return (
this.options.get('useOAuth') === true ||
this.options.get('oauth') === true
);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const {ZendeskClientVoice} = require('./clients/voice');
* @property {string[]} [apiType=['core']] - Type of Zendesk API (e.g., 'core', 'helpcenter'). Determines the sub-client to use.
* @property {string} [endpointUri] - Base URI for the Zendesk API. Overrides `subdomain` if provided.
* @property {Function} [get] - Function to retrieve specific options. Defaults to accessing properties from the options.
* @property {boolean} [oauth] - Indicates if OAuth is used.
* @property {boolean} [oauth] - Indicates if OAuth is used (this is the original OAuth flag).
* @property {boolean} [useOAuth] - Indicates if OAuth is used.
* @property {string} [asUser] - Optional header for requests on behalf of a user.
* @property {object} [customHeaders] - Additional custom headers for the request.
* @property {boolean} [throttle] - Enables request throttling.
Expand Down

0 comments on commit 15910e9

Please sign in to comment.