小编Has*_*has的帖子

获取未经授权的_client(缺少有效的授权标头)以回报 Twitter 授权 wuth next-auth

我正在尝试添加一个 Twitter 授权按钮,让我获得用户 oauth_token 和 oauth_token_secret,这允许我们的工具代表用户执行操作。

import NextAuth from "next-auth";
import TwitterProvider from "next-auth/providers/twitter";

export const authOptions = {
  // Configure one or more authentication providers
  providers: [
    TwitterProvider({
      clientId: process.env.TWITTER_CLIENT_ID,
      clientSecret: process.env.TWITTER_CLIENT_SECRET,
      version: "2.0", // opt-in to Twitter OAuth 2.0
      authorization: {
        url: "https://twitter.com/i/oauth2/authorize",
        params: {
          grant_type: "authorization_code",
          scope: "users.read tweet.read tweet.write like.read list.read",
        },
      },
    }),
    // ...add more providers here
  ],
  session: {
    strategy: "jwt",
  },
  callbacks: {
    jwt: ({ token, account, ...props }) => {
      console.log({ …
Run Code Online (Sandbox Code Playgroud)

twitter request-headers twitter-oauth reactjs next-auth

6
推荐指数
1
解决办法
1480
查看次数