passport.js

Passport js local strategy custom callback “Missing credentials”

a 夏天 提交于 2020-05-11 07:17:34
问题 I have a really annoying problem with Node js, express 4 and passport. I have tried all options I can think of, but still no solution. Couldn't find a solution from other posts for this problem. Code: app.post('/login', function(req, res, next) { console.log(req.body.user_email); console.log(req.body.user_password); passport.authenticate('local', function(err, user, info) { console.log(info); ... The problem is that for some reason, passport does not get the credentials and says at the

Authentication with React Native and API backend

假如想象 提交于 2020-05-09 17:33:52
问题 I'm trying to wrap my head around oauth with a React Native app and a separate NodeJS/Express API backend. I understand https://github.com/adamjmcgrath/react-native-simple-auth offers authentication for a React Native app and http://passportjs.org/ offers authentication for a NodeJS backend. I'm unsure how to connect these two for authentication for login and access to the API. I'd like users to login to the React Native app either by email and password or via Facebook/Twitter/Google. Once

koa passport oauth2 save token to state

心已入冬 提交于 2020-04-17 19:05:40
问题 So I'm trying to save an access token to the state within Koa, just for use later and saving having to pass it around the client. Following the passport oauth2 documentation for Koa, I'm struggling to persist anything to ctx.state ... Koa / passport oauth2 setup: server.koaApp.use(koaSession( { key: sessionKey, rolling: true, maxAge: sessionMaxAge, sameSite: 'none', secure: true, // @ts-ignore domain: undefined }, server.koaApp, )); // set up passport sessions here function createPassport() {

koa passport oauth2 save token to state

无人久伴 提交于 2020-04-17 19:05:31
问题 So I'm trying to save an access token to the state within Koa, just for use later and saving having to pass it around the client. Following the passport oauth2 documentation for Koa, I'm struggling to persist anything to ctx.state ... Koa / passport oauth2 setup: server.koaApp.use(koaSession( { key: sessionKey, rolling: true, maxAge: sessionMaxAge, sameSite: 'none', secure: true, // @ts-ignore domain: undefined }, server.koaApp, )); // set up passport sessions here function createPassport() {

Angular/Express/Passport - Authenticating with Google: No 'Access-Control-Allow-Origin

冷暖自知 提交于 2020-04-11 18:25:48
问题 Context I am building a stateless application using Angular, Express & PassportJS and want to authenticate users using their Google account. After authenticating a user, my goal is to use JWT tokens to be able to have a stateless application. Angular 2 side Upon clicking the Google sign in button, the following code gets executed in my service: login() { return this.http.get('http://localhost:3000/api/auth/google'); } Express side On express, the following gets executed: // This gets executed

middleware must be a function for koa passport testing using jest typescript

大兔子大兔子 提交于 2020-04-07 08:11:53
问题 Running into a few issues when trying to mock an oauth2 flow using passport and koa... The error when running test: TypeError: middleware must be a function! 26 | app.use(bodyParser()); > 27 | app.use(authRouting as any); | ^ auth.ts: import { KoaPassport } from 'koa-passport'; import * as Router from 'koa-router'; import { signAccessToken } from '../utils/jwt'; export function createAuthRoutes(passport: InstanceType<typeof KoaPassport>) { const router = new Router(); router.get('/api/login',

Passport - Node.js not returning Refresh Token

最后都变了- 提交于 2020-03-13 04:48:06
问题 I am trying to return a refreshToken using the passport module of node.js. However I am using the code below and I am unable to log any refresh token but the access token works fine. Is there any way to specify the access-type offline for this module to hopefully return this? var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy; passport.use(new GoogleStrategy({ clientID: GOOGLE_CLIENT_ID, clientSecret: GOOGLE_CLIENT_SECRET, callbackURL: "http://myurl/auth/callback" },

Passport - Node.js not returning Refresh Token

扶醉桌前 提交于 2020-03-13 04:48:05
问题 I am trying to return a refreshToken using the passport module of node.js. However I am using the code below and I am unable to log any refresh token but the access token works fine. Is there any way to specify the access-type offline for this module to hopefully return this? var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy; passport.use(new GoogleStrategy({ clientID: GOOGLE_CLIENT_ID, clientSecret: GOOGLE_CLIENT_SECRET, callbackURL: "http://myurl/auth/callback" },

NestJs JWT Authentication returns 401

雨燕双飞 提交于 2020-03-05 04:01:54
问题 I have implemented a jwt authentication in nestJs. However whenever I attempt to authenticate using the following authorization headers: Bearer <token> or JWT <token> I got 401. These are my authentication files @Injectable() export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') { constructor(private readonly authService: AuthService) { super({ jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(), secretOrKey: `${process.env.SECRET}`, }); } async validate(payload: Credentials

How to catch FacebookAuthorizationError in passport-facebook / Passport.js?

前提是你 提交于 2020-03-04 23:29:38
问题 I have an express app that uses Facebook authentication via Passport.js and the passport-facebook strategy. I have followed the documentation on how to handle authentication. It all works fine... until Facebook tries to report an error via the callback Url. In this case, I get an uncaught FacebookAuthorizationError exception, and the failureRedirect is not called. End users see an "Internal Server Error" as a result of the un-caught exception and I am in non-compliance with Facebook