Skip to content

Commit

Permalink
[SDK-2811] Replace request with axios (#144)
Browse files Browse the repository at this point in the history
* Replace request with got

* Use axios instead of got

* Revert changes
  • Loading branch information
frederikprijck committed Sep 28, 2021
1 parent 53dc43e commit 1aaf257
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1,916 deletions.
26 changes: 10 additions & 16 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
*/
var util = require('util'),
OAuth2Strategy = require('passport-oauth').OAuth2Strategy,
request = require('request'),
axios = require('axios'),
pkg = require('../package.json')
crypto = require('crypto');
crypto = require('crypto')
querystring = require('querystring');

function encodeClientInfo(obj) {
return Buffer.from(JSON.stringify(obj)).toString('base64');
Expand Down Expand Up @@ -159,7 +160,7 @@ Strategy.prototype.authorizationParams = function(options) {
};

/**
* TODO: Deprecate
* @deprecated An Access Token is already included as part of the verify callback passed to Auth0Strategy.
*/
Strategy.prototype._getAccessToken = function(done){
var body = {
Expand All @@ -169,23 +170,16 @@ Strategy.prototype._getAccessToken = function(done){
'grant_type': 'client_credentials'
};

request({
axios({
method: 'POST',
url: this.options.tokenURL,
form: body,
headers: {
data: querystring.stringify(body),
headers: {
'Auth0-Client': clientInfoHeader
}
}, function (err, resp, body) {

if(err) return done(err);
var result = JSON.parse(body);
var accessToken = result['access_token'];
var idToken = result['id_token'];
done(null, accessToken, idToken);
});


})
.then((response) => done(null, response.data['access_token'], response.data['id_token']))
.catch((err) => done(err));
};

/**
Expand Down
Loading

0 comments on commit 1aaf257

Please sign in to comment.