简体   繁体   English

NestJS:护照 LinkedIn 策略与 graphql

[英]NestJS : Passport LinkedIn strategy with graphql

I have nestjs application running on typescript, Graphql, Postgres with Jwt strategy defined, now I need to workout LinkedIn strategy with it.我在 typescript、Graphql、Postgres 上运行了 Nestjs 应用程序,并定义了 Jwt 策略,现在我需要用它来锻炼 LinkedIn 策略。 I am not really sure where to start with it, there are a couple of packages available but they are missing the Graphql part and they are mostly pointing to API endpoints on local like /auth/linkedin/callback , I would like to know here and how to start.我不确定从哪里开始,有几个可用的软件包,但它们缺少 Graphql 部分,它们主要指向本地的 API 端点,例如/auth/linkedin/callback ,我想知道这里和如何开始。

If you look at LinkedIn's OAuth documentatioin you'll see that LinkedIn needs to know about a callback url for when authorization attempts are successful.如果您查看LinkedIn 的 OAuth 文档,您会发现 LinkedIn 需要了解有关何时授权尝试成功的回调 url。 You'll also see that the response for the initial authroization call (what calls your callback URL) is a GET request that doesn't conform to GraphQL format, so you have to implement a REST endpoint for this.您还将看到初始授权调用(调用您的回调 URL)的响应是不符合 GraphQL 格式的 GET 请求,因此您必须为此实现 REST 端点。

This is pretty true for most OAuth2.0 calls.对于大多数OAuth2.0 调用来说,这是非常正确的。 You need to implement them in REST, not GraphQL.您需要在 REST 中实现它们,而不是 GraphQL。 If you really wanted to, you could take the REST call and do some transformation to make it a GQL call, then forward it on to your GQL server, but that's still a REST endpoint you've got in your server.如果您真的想要,您可以使用 REST 调用并进行一些转换以使其成为 GQL 调用,然后将其转发到您的 GQL 服务器,但这仍然是您在服务器中拥有的 REST 端点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM