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
I attempted different approaches to handle the 401 error, but none were successful. Could you guide me on how to effectively manage this issue in the provided code snippet?
The text was updated successfully, but these errors were encountered:
`import { Injectable } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport';
import { Strategy } from '@superfaceai/passport-twitter-oauth2';
import { Config } from 'src/utils/config';
@Injectable()
export class TwitterStrategy extends PassportStrategy(
Strategy,
'twitter-strategy',
) {
constructor() {
super({
clientID: Config.TWITTER_CLIENT_ID,
clientSecret: Config.TWITTER_CLIENT_SECRET,
clientType: 'public',
callbackURL:
${Config.BACKEND_URL}/account-verification/twitter/callback
,scope: ['users.read', 'offline.access', 'tweet.read'],
passReqToCallback: true,
state: true,
});
}
async validate(
req: any,
accessToken: string,
refreshToken: string,
profile: any,
done: any,
) {
const { id, username } = profile;
const twitter: any = {};
twitter.twitterId = id;
twitter.username = username;
done(null, twitter);
}
async authenticate(req: any, options?: any) {
try {
return super.authenticate(req, options);
} catch (error) {
if (error.statusCode === 401) {
console.log('Unauthorized')
}
throw error;
}
}
}
`
I attempted different approaches to handle the 401 error, but none were successful. Could you guide me on how to effectively manage this issue in the provided code snippet?
The text was updated successfully, but these errors were encountered: