Start 2025 on time and up to date! Seamlessly integrate your calendars into Dropbox with these simple steps! 📆
Forum Discussion
hhjj49
2 years agoNew member | Level 2
Malformed OAuth2 Access Token When Deployed to Vercel
So I just started using dropbox for a nextjs/react app and everything works fine exactly as it should when I run it locally, but when I deploy to vercel I get a 400 code and the 'Error in call to API function "files/upload": The given OAuth 2 access token is malformed.' message. I've configured my environment variables correctly because all of the other api calls in my app work correctly when deployed. I'm guessing I need to configure something in the developer dashboard to allow the access token to work on the vercel app as well as locally but I'm unsure what it is I need to do as of now. Any help would be greatly appreciated!
- Greg-DBDropbox Staff
Regardless of where/how you're performing the API call, the "The given OAuth 2 access token is malformed" error should indicate that the call failed because the access token provided in the "Authorization" header was not of the expected form. This isn't something you need to or can configure for the app on the App Console.
I suggest inspecting the actual request your deployed app is sending to the /2/files/upload endpoint to see what it is including in the "Authorization" header. I can't offer help with Vercel itself as that's not made by Dropbox, so you may need to refer to its documentation to see how you can inspect/debug it.
- hhjj49New member | Level 2
As far as I can tell the actual request from the deployed version is identical to the request sent by the local version that works correctly, and I'm unsure of what would be different with the request being made by the deployed version since it is the exact same code.
Here is the full error message:
DropboxResponseError: Response failed with a 400 code at /var/task/node_modules/dropbox/cjs/src/response.js:34:11 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async exportSpl (/var/task/.next/server/pages/api/exportSpotifyPlaylist.js:115:9) { status: 400, headers: Headers { [Symbol(map)]: [Object: null prototype] { 'cache-control': [Array], 'content-security-policy': [Array], 'x-content-type-options': [Array], 'content-type': [Array], 'accept-encoding': [Array], date: [Array], server: [Array], 'content-length': [Array], 'strict-transport-security': [Array], 'x-robots-tag': [Array], 'x-dropbox-response-origin': [Array], 'x-dropbox-request-id': [Array], connection: [Array] } }, error: 'Error in call to API function "files/upload": The given OAuth 2 access token is malformed.' }
- Greg-DBDropbox Staff
Can you clarify what you mean when you say "As far as I can tell the actual request from the deployed version is identical to the request sent by the local version"? Were you able to actually inspect the raw content of the request being sent from the deployed version? The output you shared here only shows some of the response, not the request.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,936 PostsLatest Activity: 2 hours ago
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!