I do authorization via 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,
};
},
},
],
});
And I am getting error from reddit /you sent an invalid request
How am I supposed to pass this uri in next-auth?
NEXTAUTH_URL variable is also specified
This is how next-auth inserts it into Request URL
redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fapi%2Fauth%2Fcallback%2Freddit
but I just need
http://localhost:8080
I solved it) u just need to set redirect_uri in your reddit app as
http://localhost:8080/api/auth/callback/reddit