如何在 next-auth 中传递 redirect_uri?
How to pass redirect_uri in next-auth?
我通过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
我解决了)你只需要在你的reddit应用中设置redirect_uri为
http://localhost:8080/api/auth/callback/reddit
我通过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
我解决了)你只需要在你的reddit应用中设置redirect_uri为
http://localhost:8080/api/auth/callback/reddit