@n8n/client-oauth2
Advanced tools
Comparing version 0.11.0 to 0.12.0
@@ -20,2 +20,3 @@ /// <reference types="node" /> | ||
accessTokenUri: string; | ||
authentication?: 'header' | 'body'; | ||
authorizationUri?: string; | ||
@@ -22,0 +23,0 @@ redirectUri?: string; |
@@ -1,2 +0,2 @@ | ||
import type { ClientOAuth2, ClientOAuth2Options } from './ClientOAuth2'; | ||
import type { ClientOAuth2 } from './ClientOAuth2'; | ||
import type { ClientOAuth2Token } from './ClientOAuth2Token'; | ||
@@ -6,3 +6,3 @@ export declare class CredentialsFlow { | ||
constructor(client: ClientOAuth2); | ||
getToken(opts?: Partial<ClientOAuth2Options>): Promise<ClientOAuth2Token>; | ||
getToken(): Promise<ClientOAuth2Token>; | ||
} |
@@ -10,6 +10,7 @@ "use strict"; | ||
} | ||
async getToken(opts) { | ||
async getToken() { | ||
var _a; | ||
const options = { ...this.client.options, ...opts }; | ||
const options = { ...this.client.options }; | ||
(0, utils_1.expects)(options, 'clientId', 'clientSecret', 'accessTokenUri'); | ||
const headers = { ...constants_1.DEFAULT_HEADERS }; | ||
const body = { | ||
@@ -21,9 +22,15 @@ grant_type: 'client_credentials', | ||
} | ||
const clientId = options.clientId; | ||
const clientSecret = options.clientSecret; | ||
if (options.authentication === 'body') { | ||
body.client_id = clientId; | ||
body.client_secret = clientSecret; | ||
} | ||
else { | ||
headers.Authorization = (0, utils_1.auth)(clientId, clientSecret); | ||
} | ||
const requestOptions = (0, utils_1.getRequestOptions)({ | ||
url: options.accessTokenUri, | ||
method: 'POST', | ||
headers: { | ||
...constants_1.DEFAULT_HEADERS, | ||
Authorization: (0, utils_1.auth)(options.clientId, options.clientSecret), | ||
}, | ||
headers, | ||
body, | ||
@@ -30,0 +37,0 @@ }, options); |
export { ClientOAuth2, ClientOAuth2Options, ClientOAuth2RequestObject } from './ClientOAuth2'; | ||
export { ClientOAuth2Token, ClientOAuth2TokenData } from './ClientOAuth2Token'; | ||
export type * from './types'; |
export type Headers = Record<string, string | string[]>; | ||
export type OAuth2GrantType = 'pkce' | 'authorizationCode' | 'clientCredentials'; | ||
export interface OAuth2CredentialData { | ||
clientId: string; | ||
clientSecret?: string; | ||
accessTokenUrl: string; | ||
authentication?: 'header' | 'body'; | ||
authUrl?: string; | ||
scope?: string; | ||
authQueryParameters?: string; | ||
grantType: OAuth2GrantType; | ||
ignoreSSLIssues?: boolean; | ||
oauthTokenData?: { | ||
access_token: string; | ||
refresh_token?: string; | ||
}; | ||
} |
{ | ||
"name": "@n8n/client-oauth2", | ||
"version": "0.11.0", | ||
"version": "0.12.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "src/index.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61144
519