DEV Community

Discussion on: How to Implement Login with Google in Nest JS

Collapse
 
cziermann profile image
cziermann

Thx for the Article,

But i have an problem with this.
I am using graphl with this first i had an problem that i had not an Response object i fixed this with

  getResponse(context: ExecutionContext) {
    const ctx = GqlExecutionContext.create(context);
    const res = ctx.getContext().res;
    return res;
  }
Enter fullscreen mode Exit fullscreen mode

but now i dont get any real response at all.

i debuged alot and found out that the google-strategy never calls success, error or fail to realy end the transaction.

the only function that calls these is self._oauth2.getOAuthAccessToken

but this gets also never called.
i also could not find where this function is called at all i search for this function in my node_modules folder and only found the declaration.

Thx for Help

Greetings

Collapse
 
cziermann profile image
cziermann

i think i found an fix for that.
the problem is that the oauth2 strategy is looking for req.query.code

so one fix is just write the token in the req.query.code in the getRequest function

  getRequest(context: ExecutionContext) {
    const ctx = GqlExecutionContext.create(context);
    const req = ctx.getContext().req;
    req.query.code = tokenExtractor(req);
    return req;
  }
Enter fullscreen mode Exit fullscreen mode
Collapse
 
cziermann profile image
cziermann

did think that this fixes the issue but no.
does anyone has experience with nestjs + passport (google) and graphql?