We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

Tshaniii's avatar
Tshaniii
Helpful | Level 5
2 years ago

Authentication to dropbox

1. I am developing an application, which will have about 4-6 users with different email addresses. 

2. Then I have created a dropbox app and scope is the application folder (from this account)

3. So I did the part where you get the code, from there it is redirected to here --> http://localhost:5000/auth/dropbox-redirect?code=<generated-code>

4. However, i get an error.... this endpoint is the server side and the running code is this  (ocalhost:3000/dashboard - is frontend)

 

const dbxRedirect = async (req, res, next) => {
    try {

        const { code, state } = req.query;

        console.log(`code:${code}`);
 

       
 try{
            let token =  await dbx.auth.getAccessTokenFromCode(redirectUri, code);
            // store token and invalidate state
            req.session.token = token;
            console.log(token);
            mycache.del(state);
            res.send(token);
        }catch(error){
            console.log(error);
            return next(error);
        }
};
 
DropboxResponseError: Response failed with a 400 code
at D:\GitHubProjects\docMgtSys\document-management-system\node_modules\dropbox\cjs\src\response.js:34:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async dbxRedirect (D:\GitHubProjects\docMgtSys\document-management-system\controllers\auth-controller.js:136:26) {
status: 400,
headers: Headers {
[Symbol(map)]: [Object: null prototype] {
'content-security-policy': [Array],
'content-type': [Array],
'accept-encoding': [Array],
date: [Array],
server: [Array],
'content-length': [Array],
'x-dropbox-response-origin': [Array],
'x-dropbox-request-id': [Array],
connection: [Array]
}
},
error: {
error: 'invalid_request',
error_description: 'unknown field "token_access_type"'
}
}
DropboxResponseError: Response failed with a 400 code
at D:\GitHubProjects\docMgtSys\document-management-system\node_modules\dropbox\cjs\src\response.js:34:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async dbxRedirect (D:\GitHubProjects\docMgtSys\document-management-system\controllers\auth-controller.js:136:26)