【问题标题】:How to pass redirect_uri in next-auth?如何在下一个身份验证中传递 redirect_uri?
【发布时间】:2021-12-09 20:42:16
【问题描述】:

我通过 next-auth 进行授权

import NextAuth from 'next-auth';

export default NextAuth({
    providers: [
        {
            id: 'reddit',
            name: 'Reddit',
            clientId: process.env.CLIENT_ID,
            clientSecret: process.env.CLIENT_SECRET,
            scope: 'read submit identity',
            type: 'oauth',
            version: '2.0',
            params: { grant_type: 'authorization_code' },
            accessTokenUrl: ' https://www.reddit.com/api/v1/access_token',
            authorizationUrl: 'https://www.reddit.com/api/v1/authorize?response_type=code&duration=permanent',
            profileUrl: 'https://oauth.reddit.com/api/v1/me',
            profile: profile => {
                return {
                    id: profile.id as string,
                    name: profile.name,
                    email: null,
                };
            },
        },
    ],
});

我从 reddit 收到错误消息 /你发送了一个无效的请求

  • redirect_uri 参数无效。/

我应该如何在 next-auth 中传递这个 uri?

还指定了 NEXTAUTH_URL 变量

这是 next-auth 将其插入请求 URL 的方式

redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fapi%2Fauth%2Fcallback%2Freddit

但我只需要

http://localhost:8080

【问题讨论】:

    标签: javascript reactjs next.js next-auth


    【解决方案1】:

    我解决了)你只需要在你的 reddit 应用程序中设置 redirect_uri 为

    http://localhost:8080/api/auth/callback/reddit
    

    【讨论】:

      猜你喜欢
      • 2012-03-04
      • 2021-04-20
      • 2021-09-06
      • 1970-01-01
      • 2019-07-12
      • 2021-05-26
      • 2017-11-04
      • 2021-08-17
      • 1970-01-01
      相关资源
      最近更新 更多