mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-04 03:00:05 +00:00
feat: enable insecure connection for accessToken
This commit is contained in:
@@ -701,11 +701,13 @@ export class SASViyaApiClient {
|
|||||||
* @param clientId - the client ID to authenticate with.
|
* @param clientId - the client ID to authenticate with.
|
||||||
* @param clientSecret - the client secret to authenticate with.
|
* @param clientSecret - the client secret to authenticate with.
|
||||||
* @param authCode - the auth code received from the server.
|
* @param authCode - the auth code received from the server.
|
||||||
|
* @param insecure - this boolean tells adapter to ignore SSL errors. [Not Recommended]
|
||||||
*/
|
*/
|
||||||
public async getAccessToken(
|
public async getAccessToken(
|
||||||
clientId: string,
|
clientId: string,
|
||||||
clientSecret: string,
|
clientSecret: string,
|
||||||
authCode: string
|
authCode: string,
|
||||||
|
insecure: boolean = false
|
||||||
) {
|
) {
|
||||||
const url = this.serverUrl + '/SASLogon/oauth/token'
|
const url = this.serverUrl + '/SASLogon/oauth/token'
|
||||||
let token
|
let token
|
||||||
@@ -729,12 +731,23 @@ export class SASViyaApiClient {
|
|||||||
formData.append('code', authCode)
|
formData.append('code', authCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let moreOptions = {}
|
||||||
|
if (insecure) {
|
||||||
|
const https = require('https')
|
||||||
|
moreOptions = {
|
||||||
|
agent: new https.Agent({
|
||||||
|
rejectUnauthorized: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const authResponse = await fetch(url, {
|
const authResponse = await fetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
headers,
|
headers,
|
||||||
body: formData as any,
|
body: formData as any,
|
||||||
referrerPolicy: 'same-origin'
|
referrerPolicy: 'same-origin',
|
||||||
|
...moreOptions
|
||||||
}).then((res) => res.json())
|
}).then((res) => res.json())
|
||||||
|
|
||||||
return authResponse
|
return authResponse
|
||||||
|
|||||||
@@ -389,14 +389,16 @@ export default class SASjs {
|
|||||||
public async getAccessToken(
|
public async getAccessToken(
|
||||||
clientId: string,
|
clientId: string,
|
||||||
clientSecret: string,
|
clientSecret: string,
|
||||||
authCode: string
|
authCode: string,
|
||||||
|
insecure: boolean = false
|
||||||
) {
|
) {
|
||||||
this.isMethodSupported('getAccessToken', ServerType.SASViya)
|
this.isMethodSupported('getAccessToken', ServerType.SASViya)
|
||||||
|
|
||||||
return await this.sasViyaApiClient!.getAccessToken(
|
return await this.sasViyaApiClient!.getAccessToken(
|
||||||
clientId,
|
clientId,
|
||||||
clientSecret,
|
clientSecret,
|
||||||
authCode
|
authCode,
|
||||||
|
insecure
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user