diff --git a/src/core/plugins/auth/actions.js b/src/core/plugins/auth/actions.js index 221d80a8..5524413e 100644 --- a/src/core/plugins/auth/actions.js +++ b/src/core/plugins/auth/actions.js @@ -111,7 +111,7 @@ export const authorizeApplication = ( auth ) => ( { authActions } ) => { return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth, headers }) } -export const authorizeAccessCode = ( { auth, redirectUrl } ) => ( { authActions } ) => { +export const authorizeAccessCodeWithQueryParams = ( { auth, redirectUrl } ) => ( { authActions } ) => { let { schema, name, clientId, clientSecret } = auth let form = { grant_type: "authorization_code", @@ -124,6 +124,21 @@ export const authorizeAccessCode = ( { auth, redirectUrl } ) => ( { authActions return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth}) } +export const authorizeAccessCodeWithBasicAuthentication = ( { auth, redirectUrl } ) => ( { authActions } ) => { + let { schema, name, clientId, clientSecret } = auth + let headers = { + Authorization: "Basic " + btoa(clientId + ":" + clientSecret) + } + let form = { + grant_type: "authorization_code", + code: auth.code, + client_id: clientId, + redirect_uri: redirectUrl + } + + return authActions.authorizeRequest({body: buildFormData(form), name, url: schema.get("tokenUrl"), auth, headers}) +} + export const authorizeRequest = ( data ) => ( { fn, authActions, errActions, authSelectors } ) => { let { body, query={}, headers={}, name, url, auth } = data let { additionalQueryStringParams } = authSelectors.getConfigs() || {}