You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// TODO: Instagram provides user profile information in the access token
// response. As an optimization, that information should be used, which
// 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.
we don't need to make a second call to the Instagram API here if we just need basic information.
But we don't have to rewrite the oauth2 module, because it already gives us the data we need. So if you only need the basic information, you can avoid a second network request with the following trick:
pass skipUserProfile: true to the options and add one parameter to the callback function, as shown in the following example:
passport.use(newInstagramStrategy({clientID: config.instagram.clientID,clientSecret: config.instagram.clientSecret,callbackURL: `https://${siteurl}/auth/instagram/callback`,passReqToCallback: true,skipUserProfile: true,},(req,accessToken,refreshToken,params,_profile,done)=>{console.log(params)if(typeofparams==='undefined'||params===null||params==={}){returndone(newError('invalid data from instagram'))}constprofile=params.userreturndoRegisterOrLogin(req,profile,done)}))
As you can see, we can skip the second request and the params object looks something similar to this:
As Jared already said in
passport-instagram/lib/strategy.js
Lines 73 to 77 in d78c551
But we don't have to rewrite the oauth2 module, because it already gives us the data we need. So if you only need the basic information, you can avoid a second network request with the following trick:
pass
skipUserProfile: true
to the options and add one parameter to the callback function, as shown in the following example:Before:
After:
As you can see, we can skip the second request and the params object looks something similar to this:
This helped us a lot, because many requests (around 4%) failed on the second request (because of 'internal server error's from instagram)
The text was updated successfully, but these errors were encountered: