One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
njclonch
8 years agoExplorer | Level 3
Access token is not being accepted from local server
After successfully receiving an access token from the `oauth2/authorize` endpoint, I have attempted to submit the access token to `sharing/get_shared_link_metadata` along with the URL of a shared link. Several attempts have returned me with a 401 error. So I tried submitting an access token, which was generated from the app page, but with no success. However, when I copied/pasted my code to phpfiddle.com, the request returned successfully. So the issue seems to exist only in the request from my virtual server.
I have no clue what issue could exist in a request from a virtual server, so any help would be greatly appreciated.
- Greg-DB
Dropbox Staff
Can you share your code and the full error response? Thanks in advance!- njclonchExplorer | Level 3
request:
public function getDropboxMetadata($url, $token) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.dropboxapi.com/2/sharing/get_shared_link_metadata'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer ' . $token, 'Content-Type: application/json']); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['url' => $url])); $result = curl_exec($ch); curl_close($ch); return $result; }
response:
error: { code: 401, errors: { 0: { domain: "global", location: "Authorization", locationType: "header", message: "Invalid Credentials", reason: "authError" } }, message: "Invalid Credentials" }
- Greg-DB
Dropbox Staff
Thanks! I just tried this out, and it's working for me.
Are you sure you're passing in a valid access token? I recommend printing out the $token just before you set the headers. It should be a 64 character string consisting of letters, numbers, and some symbols.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 13 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!