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

passport-facebook-token doesn't work #70

Closed
ivanvs opened this issue May 2, 2019 · 7 comments
Closed

passport-facebook-token doesn't work #70

ivanvs opened this issue May 2, 2019 · 7 comments

Comments

@ivanvs
Copy link

ivanvs commented May 2, 2019

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When I try to use passport-facebook-token library with this library I am getting this error:

TypeError: Class extends value undefined is not a constructor or null

/home/mrav/projects/gitdiagram-server/node_modules/@nestjs/passport/dist/passport/passport.strategy.js:13 class MixinStrategy extends Strategy {

I am trying to use given library like this:

import Strategy from "passport-facebook-token";
import { Injectable } from "@nestjs/common";
import { PassportStrategy } from "@nestjs/passport";

@Injectable()
export class GitHubStrategy extends PassportStrategy(Strategy) {
  constructor() {
    super({
      clientID: "client_id",
      clientSecret: "client_secret",
      passReqToCallback: true
    });
  }

  async validate(
    request: any,
    accessToken: string,
    refreshToken: string,
    profile,
    next: Function
  ) {
    try {
      console.log(profile);

      next(null, profile);
    } catch (err) {
      console.log(err);
      next(err, null);
    }
  }
}

I think that main problem is that passport-facebook-token is creating strategy by extending OAuth2Strategy and other libraries like passport-facebook are using util.inherits method. In node documentation util.inherits is deprecated.

As I can see nestjs/passport library is expecting Strategy to be function, link to source code.

Why I want to use passport-facebook-token strategy, because I want to implement implicit grant flow for my SPA application.

I have found one more library that is creating strategy in the same way:

  • passport-github-token

Expected behavior

It would be nice if library would support strategies that are created by extending OAuth2Strategy.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: 6.0.0

 
For Tooling issues:
- Node version: v8.15.0 
- Platform:  Ubuntu

Others:

@ivanvs ivanvs changed the title passport-facebook-token doesn't working passport-facebook-token doesn't work May 3, 2019
@kamilmysliwiec
Copy link
Member

Please, provide a minimal repository which reproduces your issue.

@ivanvs
Copy link
Author

ivanvs commented May 12, 2019

Hi Kamil,

You can find simple example here: https://github.com/ivanvs/nestjs-passport-facebook-token-example

This example is not finished, so the whole flow for authentication is not implemented. I just put implementation of strategy and that implementation cannot be compiled.

If you need anything else, please do not hesitate to contact me.

@A-aras
Copy link

A-aras commented May 21, 2019

any update on this issue

@ivanvs
Copy link
Author

ivanvs commented May 24, 2019

@kamilmysliwiec would you be interested in PR that is fixing this issue? I can try to create a fix, and then you could review my solution.

What do you think about that?

@kamilmysliwiec
Copy link
Member

Shouldn't this be fixed on the library (strategy) side instead? Also, are you sure that your issue isn't caused by the synthetic default import?

@ivanvs
Copy link
Author

ivanvs commented Jul 24, 2019

It was my mistake. Sorry for wasting your time :(

@ivanvs ivanvs closed this as completed Jul 24, 2019
@shelooks16
Copy link

shelooks16 commented Aug 15, 2019

@ivanvs I bumped into exactly same issue:

TypeError: Class extends value undefined is not a constructor or null

I took the original package and transpiled it with @babel-plugin-transform-classes so now it returns a function.
https://www.npmjs.com/package/passport-facebook-token-nest

Works as expected:

import { Strategy } from 'passport-facebook-token-nest';

export class FacebookStrategy extends PassportStrategy(Strategy, 'facebook') {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants