@sasjs/adapter 3.7.7 → 3.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -5
- package/index.js +2 -2
- package/node/index.js +2 -2
- package/package.json +1 -1
- package/src/auth/getAccessTokenForViya.ts +7 -17
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SasAuthResponse } from '@sasjs/utils/types'
|
|
2
2
|
import { prefixMessage } from '@sasjs/utils/error'
|
|
3
|
-
import * as NodeFormData from 'form-data'
|
|
4
3
|
import { RequestClient } from '../request/RequestClient'
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -24,26 +23,17 @@ export async function getAccessTokenForViya(
|
|
|
24
23
|
token = Buffer.from(clientId + ':' + clientSecret).toString('base64')
|
|
25
24
|
}
|
|
26
25
|
const headers = {
|
|
27
|
-
Authorization: 'Basic ' + token
|
|
26
|
+
Authorization: 'Basic ' + token,
|
|
27
|
+
Accept: 'application/json'
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
formData = new FormData()
|
|
35
|
-
}
|
|
36
|
-
formData.append('grant_type', 'authorization_code')
|
|
37
|
-
formData.append('code', authCode)
|
|
30
|
+
const data = new URLSearchParams({
|
|
31
|
+
grant_type: 'authorization_code',
|
|
32
|
+
code: authCode
|
|
33
|
+
})
|
|
38
34
|
|
|
39
35
|
const authResponse = await requestClient
|
|
40
|
-
.post(
|
|
41
|
-
url,
|
|
42
|
-
formData,
|
|
43
|
-
undefined,
|
|
44
|
-
'multipart/form-data; boundary=' + (formData as any)._boundary,
|
|
45
|
-
headers
|
|
46
|
-
)
|
|
36
|
+
.post(url, data, undefined, 'application/x-www-form-urlencoded', headers)
|
|
47
37
|
.then((res) => res.result as SasAuthResponse)
|
|
48
38
|
.catch((err) => {
|
|
49
39
|
throw prefixMessage(err, 'Error while getting access token. ')
|