diff --git a/src/client/oauth.js b/src/client/oauth.js index 36f521c..b532275 100644 --- a/src/client/oauth.js +++ b/src/client/oauth.js @@ -12,6 +12,8 @@ import axios from 'axios'; * @param {Object} authOptions * @property {String} authOptions.host * @property {String} authOptions.clientId + * @property {String} [options.clientSecret] + * @property {String} [options.scope] * @property {Function} [authOptions.getToken] * @property {Function} [authOptions.setToken] * @returns {Object} @@ -21,6 +23,8 @@ export default function oAuth(request, authOptions) { const { host = '', clientId = '', + clientSecret = '', + scope = '', getToken = () => memToken, setToken = (t) => { memToken = t; }, } = authOptions; @@ -163,7 +167,7 @@ export default function oAuth(request, authOptions) { 'Content-Type': 'application/x-www-form-urlencoded', Accept: 'json', }, - data: `grant_type=password&username=${user}&password=${password}&client_id=${clientId}`, + data: `grant_type=client_credentials&username=${user}&password=${password}&client_id=${clientId}&scope=${scope}&client_secret=${clientSecret}`, }).then(res => parseToken(res.data)).catch((error) => { throw error; }), getToken, };