1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-11 06:10:05 +00:00

fix(refreshTokensForViya): added throw error if not Node

This commit is contained in:
Yury Shkoda
2023-04-21 11:03:41 +03:00
parent a71d422528
commit 8360519408
2 changed files with 18 additions and 1 deletions

View File

@@ -17,6 +17,10 @@ export async function refreshTokensForViya(
clientSecret: string,
refreshToken: string
) {
if (!isNode()) {
throw new Error(`Method 'refreshTokensForViya' can only be used by Node.`)
}
const url = '/SASLogon/oauth/token'
const token =
typeof Buffer === 'undefined'
@@ -27,7 +31,7 @@ export async function refreshTokensForViya(
Authorization: 'Basic ' + token
}
const formData = isNode() ? new NodeFormData() : new FormData()
const formData = new NodeFormData()
formData.append('grant_type', 'refresh_token')
formData.append('refresh_token', refreshToken)