Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to pass Options to auth.express.authenticate. Needed for Google API refreshToken #576

Closed
nsainaney opened this Issue Sep 20, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@nsainaney
Copy link

nsainaney commented Sep 20, 2017

Google API's require that passport.authenticate is called with accessType: offline if you require the refreshToken

The following auth.ts does not get the refreshToken:

import * as auth from 'feathers-authentication'
import * as jwt from 'feathers-authentication-jwt'
import * as oauth2 from 'feathers-authentication-oauth2'
import { Strategy as GoogleStrategy } from 'passport-google-oauth20'

export default function () {
	const app = this
	let config = app.get('auth') || {}

	app.configure(auth(config))
	app.configure(jwt())
	app.configure(oauth2({
		name: 'google',
		Strategy: GoogleStrategy,
                accessType: 'offline'
	}))
        ...

The following works but it's hacky

import * as auth from 'feathers-authentication'
import * as jwt from 'feathers-authentication-jwt'
import * as oauth2 from 'feathers-authentication-oauth2'
import { Strategy as GoogleStrategy } from 'passport-google-oauth20'
export default function () {
	const app = this
	let config = app.get('auth') || {}

        // Override the /auth/google handler to replace the current handler commented below
	// app.get(oauth2Settings.path, auth.express.authenticate(name));	
	app.get('/auth/google', auth.express.authenticate('google', {
	 	"accessType": "offline",
	 	"prompt": "consent"
	}))
	
	app.configure(auth(config))
	app.configure(jwt())
	app.configure(oauth2({
		name: 'google',
		Strategy: GoogleStrategy
	}))

@nsainaney nsainaney changed the title No way to pass Options auth.express.authenticate. Needed for Google API refreshToken No way to pass Options to auth.express.authenticate. Needed for Google API refreshToken Sep 20, 2017

@daffl

This comment has been minimized.

Copy link
Member

daffl commented Sep 21, 2017

Indeed. Looks like the additional options have to be added in https://github.com/feathersjs/feathers-authentication-oauth2/blob/master/src/index.js#L70

@nsainaney

This comment has been minimized.

Copy link
Author

nsainaney commented Sep 22, 2017

Issue is not with this repo - closing the issue

@nsainaney nsainaney closed this Sep 22, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.