Open wrong7 opened 1 year ago
Fixed it with the following settings:
import DropboxProvider from "next-auth/providers/dropbox";
import type { BaseClient } from "openid-client";
import type { TokenEndpointHandler, UserinfoEndpointHandler } from "next-auth/providers";
type DropboxClient = BaseClient & {
redirect_uris: string[];
}
DropboxProvider({
clientId: process.env.DROPBOX_CLIENT_ID,
clientSecret: process.env.DROPBOX_CLIENT_SECRET,
token: {
url: "https://api.dropboxapi.com/oauth2/token",
async request(context) {
const client: DropboxClient = context.client as DropboxClient;
const token = context.provider.token as Required<TokenEndpointHandler>
const res = await fetch(token.url, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: new URLSearchParams({
code: context.params.code as string,
grant_type: "authorization_code",
code_verifier: context.checks.code_verifier as string,
client_id: context.provider.clientId as string,
client_secret: context.provider.clientSecret as string,
redirect_uri: client.redirect_uris[0],
}),
});
return {
tokens: await res.json()
};
}
},
userinfo: {
url: "https://api.dropboxapi.com/2/users/get_current_account",
async request({provider, tokens}) {
const userinfo = provider.userinfo as Required<UserinfoEndpointHandler>;
const res = await fetch(userinfo.url, {
method: "POST",
headers: {
"Authorization": `Bearer ${tokens.access_token}`,
}
});
return await res.json();
}
},
})
Provider type
Dropbox
Environment
System: OS: Windows 10 10.0.19044 CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor Memory: 5.36 GB / 15.93 GB Binaries: Node: 18.12.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 9.6.5 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.19041.1266.0), Chromium (114.0.1823.82) Internet Explorer: 11.0.19041.1566
Reproduction URL
Private
Describe the issue
Whenever I try to log in with the Dropbox provider I get this error:
The issue might be on the token URI
https://api.dropboxapi.com/oauth2/token
which if access withGET
method it returns a 404, but withPOST
it works fineHow to reproduce
Use dropbox provider
Expected behavior
There should not be an error