Skip to content

Commit

Permalink
fix: apply jaredhanson#26
Browse files Browse the repository at this point in the history
  • Loading branch information
brookmg committed Jan 12, 2022
1 parent 9cb94c2 commit 8427f97
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function Strategy(options, verify) {

OAuth2Strategy.call(this, options, verify);
this.name = 'instagram';
this._profileURL = 'https://graph.instagram.com/me?fields=username,media_count,id,account_type';
}

/**
Expand Down Expand Up @@ -75,19 +76,15 @@ Strategy.prototype.userProfile = function(accessToken, done) {
// would avoid the need for an extra request during this step. However,
// the internal node-oauth module will have to be modified to support
// exposing this information.

this._oauth2.get('https://api.instagram.com/v1/users/self', accessToken, function (err, body, res) {
this._oauth2.get(this._profileURL, accessToken, function (err, body, res) {
if (err) { return done(new InternalOAuthError('failed to fetch user profile', err)); }

try {
var json = JSON.parse(body);

var profile = { provider: 'instagram' };
profile.id = json.data.id;
profile.displayName = json.data.full_name;
profile.name = { familyName: json.data.last_name,
givenName: json.data.first_name };
profile.username = json.data.username;
profile.id = json.id;
profile.username = json.username;

profile._raw = body;
profile._json = json;
Expand All @@ -98,8 +95,6 @@ Strategy.prototype.userProfile = function(accessToken, done) {
}
});
}


/**
* Expose `Strategy`.
*/
Expand Down

0 comments on commit 8427f97

Please sign in to comment.