How can a script or app get a shareable Dropbox link?
I'm trying to automate a task I've been doing for a while that's taking way too much time, and it requires me to send a sharable link to someone for some files in my Dropbox. So I have a script I've written but ... where I'd normally right-click to get a sharable link for a file, how can I get such a link within the script? I know the file locally on my machine, but how can I get a sharable Dropbox link? Can I use the Dropbox API for that? or is there a simpler way?
Hah..😯 You said "I have a script I've written but...", but seems you don't have too much experience, since can distinguish one of the most popular scripting languages - Python. Some parts of the official Dropbox application is implemented in the same language also. Even more, it's mentioned in the script header line. Didn't you read it? Anyway... it's my wrong assumption; I'll try to be more descriptive.
Oh... The script, I linked to, targets Mac and Linux only; on Windows can run but not in the same form. I just made some tweaks to let it work on Windows. Since it's Python script, you have to have Python interpreter installed, if you haven't yet, to be able run it. So first download and install the interpreter from here. Make sure you have selected all accessibility on install time:
Once the interpreter installed you may need some additional packages available, so make sure they are there. Execute following commands in terminal window:
Now you have everything needed to run the script that let you get Dropbox links. The following is updated script version, working on Windows too:
#!/usr/bin/python3
###############################################################################
# Script receiving Dropbox links based on referred local files/folders
# --------------------------------------------------------------------
# Every target file/folder is passed as argument to the script. Resulted links
# are passed in the same sequence one per line to standard output (incorrect
# are skipped).
# Two preparation steps are needed:
# 1. Register a Dropbox application and put the application key as value of
# APPLICATION_KEY global variable.
# 2. Register the used REDIRECT_URI in the application just created in
# previous step. With host 'localhost' and port 8080, the redirect URL
# that has to be registered is "http://localhost:8080/", for instance.
# Next, just make it executable (if needed), using:
# $ chmod a+x get_dropbox_link
# ... and put it in a place visible for execution in your system (somewhere in
# folders pointed by $PATH environment variable). On first run you will be
# invited to link your script to your Dropbox account. To work correct local
# Dropbox application and this script have to be link to the same account!
# Verified on Dropbox v172.4.7555
# Author: Здравко
# www.dropboxforum.com/t5/user/viewprofilepage/user-id/422790
###############################################################################
from dropbox import Dropbox, DropboxOAuth2Flow
from dropbox.exceptions import ApiError
from dropbox.oauth import NotApprovedException
import json
from pathlib import Path
from datetime import datetime
from os import sep, name, makedirs
from sys import exit
import logging
from platformdirs import user_config_path
# Place to save current configuration
CONFIG_JSON=user_config_path('get_dropbox_link') / 'cred.json'
# Take a look on your application in https://www.dropbox.com/developers/apps
APPLICATION_KEY='PUT YOUR KEY HERE'
URI_HOST='localhost'
URI_PORT=8080
# URI should be registered in the application redirect URIs list!!!
REDIRECT_URI=f"http://{URI_HOST}:{URI_PORT}/"
success_response = "End of authentication flow. 😉 Your can get a link!"
cancel_response = "🤷 You have denied your application's work. 😕"
error_response = "😈 You got an error: "
class ApplicationConfig:
def __init__(self, conf_path=CONFIG_JSON):
self.conf_path=Path(conf_path).expanduser()
self.conf=None
self.client=None
self.access_token=None
self.access_token_expiresat=None
self.refresh_token=None
makedirs(self.conf_path.parent, exist_ok=True)
if self.conf_path.is_file():
try:
with self.conf_path.open() as fconf:
self.conf=json.load(fconf)
self.access_token = self.conf['access_token']
self.access_token_expiresat = datetime.fromtimestamp(
self.conf['access_token_expiresat'])
self.refresh_token = self.conf['refresh_token']
except Exception:
self.conf_path.unlink(True)
self.conf=None
def __del__(self):
"Checks for something changed (new access token) and dumps it when there is"
if (self.client is not None and
self.client._oauth2_access_token_expiration >
self.access_token_expiresat):
self.conf['access_token'] = self.client._oauth2_access_token
self.conf['access_token_expiresat'] = (
self.client._oauth2_access_token_expiration.timestamp())
self.conf['refresh_token'] = self.client._oauth2_refresh_token
with self.conf_path.open(mode='w') as fconf:
json.dump(self.conf, fconf)
def getClient(self):
"Gets Dropbox client object. Performs OAuth flow if needed."
if self.conf is None:
self.client=None
import webbrowser
from http.server import HTTPServer, BaseHTTPRequestHandler
dbxAuth=DropboxOAuth2Flow(APPLICATION_KEY, REDIRECT_URI, {},
'dropbox-auth-csrf-token', token_access_type='offline', use_pkce=True)
webbrowser.open(dbxAuth.start())
conf=None
conf_path = self.conf_path
class Handler(BaseHTTPRequestHandler):
response_success = success_response.encode()
response_cancel = cancel_response.encode()
response_error = error_response.encode()
def do_GET(self):
nonlocal dbxAuth, conf
from urllib.parse import urlparse, parse_qs
query = parse_qs(urlparse(self.path).query)
for r in query.keys():
query[r] = query[r][0]
self.send_response(200)
self.send_header("content-type", "text/plain;charset=UTF-8")
try:
oauthRes = dbxAuth.finish(query)
conf={'access_token': oauthRes.access_token,
'access_token_expiresat': oauthRes.expires_at.timestamp(),
'refresh_token': oauthRes.refresh_token}
with conf_path.open(mode='w') as fconf:
json.dump(conf, fconf)
except NotApprovedException:
conf={}
self.send_header("content-length", f"{len(Handler.response_cancel)}")
self.end_headers()
self.wfile.write(Handler.response_cancel)
self.wfile.flush()
return
except Exception as e:
conf={}
r = Handler.response_error + str(e).encode()
self.send_header("content-length", f"{len(r)}")
self.end_headers()
self.wfile.write(r)
self.wfile.flush()
return
self.send_header("content-length", f"{len(Handler.response_success)}")
self.end_headers()
self.wfile.write(Handler.response_success)
self.wfile.flush()
httpd=HTTPServer((URI_HOST, URI_PORT), Handler)
while conf is None:
httpd.handle_request()
httpd.server_close()
del httpd
if 'refresh_token' not in conf:
raise RuntimeError("Cannot process because missing authentication")
self.conf = conf
self.access_token = self.conf['access_token']
self.access_token_expiresat = datetime.fromtimestamp(
self.conf['access_token_expiresat'])
self.refresh_token = self.conf['refresh_token']
# Makes sure there is cached client object.
if self.client is None:
self.client=Dropbox(self.access_token,
oauth2_refresh_token=self.refresh_token,
oauth2_access_token_expiration=self.access_token_expiresat,
app_key=APPLICATION_KEY)
return self.client
class PathMapper:
def __init__(self):
if name == 'nt':
dbx_info = user_config_path() / 'Dropbox' / 'info.json'
else:
dbx_info = Path('~/.dropbox/info.json').expanduser()
if not dbx_info.is_file():
raise RuntimeError("Missing Dropbox application information")
with dbx_info.open() as finfo:
# Only personal accounts are supported by now - group accounts need
# additional namespace handling (just changing 'personal' is not enough).
# Somebody else may make some exercises.
self.dbx_path = json.load(finfo)['personal']['path']
def __contains__(self, path):
path = str(Path(path).expanduser().absolute())
return ((len(path) == len(self.dbx_path) and path == self.dbx_path) or
(len(path) > len(self.dbx_path) and path[len(self.dbx_path)] == sep
and path[:len(self.dbx_path)] == self.dbx_path))
def __getitem__(self, path):
path = str(Path(path).expanduser().absolute())
if ((len(path) == len(self.dbx_path) and path == self.dbx_path) or
(len(path) > len(self.dbx_path) and path[len(self.dbx_path)] == sep
and path[:len(self.dbx_path)] == self.dbx_path)):
return Path(path[len(self.dbx_path):]).as_posix()
def main():
import argparse
dbxPathMap = PathMapper()
parser = argparse.ArgumentParser(description="Fetch Dropbox URL for path")
parser.add_argument("paths", type=str, nargs="+", help="paths to files")
parser.add_argument("--verbose", "-v", action="store_true",
help="toggle verbose mode")
args = parser.parse_args()
del parser
if args.verbose:
logging.basicConfig(level=logging.DEBUG)
conf = ApplicationConfig()
dbx = conf.getClient()
for path in args.paths:
if path not in dbxPathMap:
logging.error(f"Passed path '{path}' is not part of the Dropbox driectory tree")
continue
dbx_path = dbxPathMap[path]
if len(dbx_path) == 0:
logging.error("Dropbox folder itself cannot be pointed by link")
continue
logging.debug(f"Processing local file '{path}' with Dropbox path '{dbx_path}'")
try:
metadata = dbx.sharing_create_shared_link_with_settings(dbx_path)
except ApiError as e:
er = e.error
if not er.is_shared_link_already_exists():
raise
er = er.get_shared_link_already_exists()
if not er.is_metadata():
raise
metadata = er.get_metadata()
print(metadata.url)
if __name__ == "__main__":
try:
main()
except Exception as e:
logging.error(f"Unexpected error: {e}")
exit(1)
Save above script in a file named "get_dropbox_link" on place convenient for you. Since this script uses Dropbox API, you need to register your application here. Select "Full Dropbox" as access type, since you will need access to files in entire account, not only application specific files. Make sure "sharing.write" is selected scope in your application permission (to be able create and get shared links). In section Redirect URIs, ensure URL "http://localhost:8080/" is present (add it as needed). On the same page is field named App key; copy the value/key shown there to corresponding place in the script (near beginning - it's the only redaction you have to make). Now you're almost ready. Type in the terminal something like:
py <exec path to>\get_dropbox_link <path into Dropbox>
Here <exec path to> is optional path to the place you put the script on. You may need to use such explicit path when the script is not directly visible from the place you're calling from. <path into Dropbox> is path to file/folder, residing within your local Dropbox folder, you want to get shared link to. That's it. 😉 You can ether extend this script and/or call it from any other script (doesn't have to be Python script; can be any other script).
Good luck.
About Create, upload, and share
Find help to solve issues with creating, uploading, and sharing files and folders in Dropbox. Get support and advice from the Dropbox Community.
Need more support
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!
Start 2025 on time and up to date. Seamlessly integrate your calendars into Dropbox with these simple steps.
"}},"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"components/community/NavbarDropdownToggle\"]})":[{"__ref":"CachedAsset:text:en_US-components/community/NavbarDropdownToggle-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"components/messages/EscalatedMessageBanner\"]})":[{"__ref":"CachedAsset:text:en_US-components/messages/EscalatedMessageBanner-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"components/users/UserLink\"]})":[{"__ref":"CachedAsset:text:en_US-components/users/UserLink-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"shared/client/components/users/UserRank\"]})":[{"__ref":"CachedAsset:text:en_US-shared/client/components/users/UserRank-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"components/messages/MessageTime\"]})":[{"__ref":"CachedAsset:text:en_US-components/messages/MessageTime-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"components/messages/MessageSubject\"]})":[{"__ref":"CachedAsset:text:en_US-components/messages/MessageSubject-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"components/messages/MessageBody\"]})":[{"__ref":"CachedAsset:text:en_US-components/messages/MessageBody-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"components/messages/MessageCustomFields\"]})":[{"__ref":"CachedAsset:text:en_US-components/messages/MessageCustomFields-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"components/messages/MessageReplyButton\"]})":[{"__ref":"CachedAsset:text:en_US-components/messages/MessageReplyButton-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"components/messages/AcceptedSolutionButton\"]})":[{"__ref":"CachedAsset:text:en_US-components/messages/AcceptedSolutionButton-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"shared/client/components/common/Pager/PagerLoadMore\"]})":[{"__ref":"CachedAsset:text:en_US-shared/client/components/common/Pager/PagerLoadMore-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"components/nodes/NodeView/NodeViewCard\"]})":[{"__ref":"CachedAsset:text:en_US-components/nodes/NodeView/NodeViewCard-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"components/messages/MessageView/MessageViewInline\"]})":[{"__ref":"CachedAsset:text:en_US-components/messages/MessageView/MessageViewInline-1737382617494"}],"message({\"id\":\"message:680739\"})":{"__ref":"ForumReplyMessage:message:680739"},"message({\"id\":\"message:680821\"})":{"__ref":"ForumReplyMessage:message:680821"},"message({\"id\":\"message:680928\"})":{"__ref":"ForumReplyMessage:message:680928"},"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"shared/client/components/users/UserAvatar\"]})":[{"__ref":"CachedAsset:text:en_US-shared/client/components/users/UserAvatar-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"shared/client/components/ranks/UserRankLabel\"]})":[{"__ref":"CachedAsset:text:en_US-shared/client/components/ranks/UserRankLabel-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"shared/client/components/nodes/NodeAvatar\"]})":[{"__ref":"CachedAsset:text:en_US-shared/client/components/nodes/NodeAvatar-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"shared/client/components/nodes/NodeDescription\"]})":[{"__ref":"CachedAsset:text:en_US-shared/client/components/nodes/NodeDescription-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"components/tags/TagView/TagViewChip\"]})":[{"__ref":"CachedAsset:text:en_US-components/tags/TagView/TagViewChip-1737382617494"}],"cachedText({\"lastModified\":\"1737382617494\",\"locale\":\"en-US\",\"namespaces\":[\"shared/client/components/nodes/NodeIcon\"]})":[{"__ref":"CachedAsset:text:en_US-shared/client/components/nodes/NodeIcon-1737382617494"}]},"CachedAsset:pages-1736942066867":{"__typename":"CachedAsset","id":"pages-1736942066867","value":[{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"BlogViewAllPostsPage","type":"BLOG","urlPath":"/category/:categoryId/blog/:boardId/all-posts/(/:after|/:before)?","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"CasePortalPage","type":"CASE_PORTAL","urlPath":"/caseportal","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"CreateGroupHubPage","type":"GROUP_HUB","urlPath":"/groups/create","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"CaseViewPage","type":"CASE_DETAILS","urlPath":"/case/:caseId/:caseNumber","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"InboxPage","type":"COMMUNITY","urlPath":"/inbox","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"HelpFAQPage","type":"COMMUNITY","urlPath":"/help","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"IdeaMessagePage","type":"IDEA_POST","urlPath":"/idea/:boardId/:messageSubject/:messageId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"IdeaViewAllIdeasPage","type":"IDEA","urlPath":"/category/:categoryId/ideas/:boardId/all-ideas/(/:after|/:before)?","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"LoginPage","type":"USER","urlPath":"/signin","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"BlogPostPage","type":"BLOG","urlPath":"/category/:categoryId/blogs/:boardId/create","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"ThemeEditorPage","type":"COMMUNITY","urlPath":"/designer/themes","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"TkbViewAllArticlesPage","type":"TKB","urlPath":"/category/:categoryId/kb/:boardId/all-articles/(/:after|/:before)?","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"OccasionEditPage","type":"EVENT","urlPath":"/event/:boardId/:messageSubject/:messageId/edit","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"OAuthAuthorizationAllowPage","type":"USER","urlPath":"/auth/authorize/allow","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"PageEditorPage","type":"COMMUNITY","urlPath":"/designer/pages","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"PostPage","type":"COMMUNITY","urlPath":"/category/:categoryId/:boardId/create","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"ForumBoardPage","type":"FORUM","urlPath":"/category/:categoryId/discussions/:boardId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"TkbBoardPage","type":"TKB","urlPath":"/category/:categoryId/kb/:boardId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"EventPostPage","type":"EVENT","urlPath":"/category/:categoryId/events/:boardId/create","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"UserBadgesPage","type":"COMMUNITY","urlPath":"/users/:login/:userId/badges","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"GroupHubMembershipAction","type":"GROUP_HUB","urlPath":"/membership/join/:nodeId/:membershipType","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"IdeaReplyPage","type":"IDEA_REPLY","urlPath":"/idea/:boardId/:messageSubject/:messageId/comments/:replyId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"UserSettingsPage","type":"USER","urlPath":"/mysettings/:userSettingsTab","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"GroupHubsPage","type":"GROUP_HUB","urlPath":"/groups","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"ForumPostPage","type":"FORUM","urlPath":"/category/:categoryId/discussions/:boardId/create","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"OccasionRsvpActionPage","type":"OCCASION","urlPath":"/event/:boardId/:messageSubject/:messageId/rsvp/:responseType","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"VerifyUserEmailPage","type":"USER","urlPath":"/verifyemail/:userId/:verifyEmailToken","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"AllOccasionsPage","type":"OCCASION","urlPath":"/category/:categoryId/events/:boardId/all-events/(/:after|/:before)?","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"EventBoardPage","type":"EVENT","urlPath":"/category/:categoryId/events/:boardId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"TkbReplyPage","type":"TKB_REPLY","urlPath":"/kb/:boardId/:messageSubject/:messageId/comments/:replyId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"IdeaBoardPage","type":"IDEA","urlPath":"/category/:categoryId/ideas/:boardId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"CommunityGuideLinesPage","type":"COMMUNITY","urlPath":"/communityguidelines","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"CaseCreatePage","type":"SALESFORCE_CASE_CREATION","urlPath":"/caseportal/create","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"TkbEditPage","type":"TKB","urlPath":"/kb/:boardId/:messageSubject/:messageId/edit","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"ForgotPasswordPage","type":"USER","urlPath":"/forgotpassword","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"IdeaEditPage","type":"IDEA","urlPath":"/idea/:boardId/:messageSubject/:messageId/edit","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"TagPage","type":"COMMUNITY","urlPath":"/tag/:tagName","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"BlogBoardPage","type":"BLOG","urlPath":"/category/:categoryId/blog/:boardId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"OccasionMessagePage","type":"OCCASION_TOPIC","urlPath":"/event/:boardId/:messageSubject/:messageId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"ManageContentPage","type":"COMMUNITY","urlPath":"/managecontent","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"ClosedMembershipNodeNonMembersPage","type":"GROUP_HUB","urlPath":"/closedgroup/:groupHubId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"CommunityPage","type":"COMMUNITY","urlPath":"/","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"ForumMessagePage","type":"FORUM_TOPIC","urlPath":"/discussions/:boardId/:messageSubject/:messageId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"IdeaPostPage","type":"IDEA","urlPath":"/category/:categoryId/ideas/:boardId/create","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"BlogMessagePage","type":"BLOG_ARTICLE","urlPath":"/blog/:boardId/:messageSubject/:messageId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"RegistrationPage","type":"USER","urlPath":"/register","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"EditGroupHubPage","type":"GROUP_HUB","urlPath":"/group/:groupHubId/edit","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"ForumEditPage","type":"FORUM","urlPath":"/discussions/:boardId/:messageSubject/:messageId/edit","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"ResetPasswordPage","type":"USER","urlPath":"/resetpassword/:userId/:resetPasswordToken","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"TkbMessagePage","type":"TKB_ARTICLE","urlPath":"/kb/:boardId/:messageSubject/:messageId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"BlogEditPage","type":"BLOG","urlPath":"/blog/:boardId/:messageSubject/:messageId/edit","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"ManageUsersPage","type":"USER","urlPath":"/users/manage/:tab?/:manageUsersTab?","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"ForumReplyPage","type":"FORUM_REPLY","urlPath":"/discussions/:boardId/:messageSubject/:messageId/replies/:replyId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"PrivacyPolicyPage","type":"COMMUNITY","urlPath":"/privacypolicy","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"NotificationPage","type":"COMMUNITY","urlPath":"/notifications","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"UserPage","type":"USER","urlPath":"/users/:login/:userId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"OccasionReplyPage","type":"OCCASION_REPLY","urlPath":"/event/:boardId/:messageSubject/:messageId/comments/:replyId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"ManageMembersPage","type":"GROUP_HUB","urlPath":"/group/:groupHubId/manage/:tab?","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"SearchResultsPage","type":"COMMUNITY","urlPath":"/search","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"BlogReplyPage","type":"BLOG_REPLY","urlPath":"/blog/:boardId/:messageSubject/:messageId/replies/:replyId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"GroupHubPage","type":"GROUP_HUB","urlPath":"/group/:groupHubId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"TermsOfServicePage","type":"COMMUNITY","urlPath":"/termsofservice","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"CategoryPage","type":"CATEGORY","urlPath":"/category/:categoryId","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"ForumViewAllTopicsPage","type":"FORUM","urlPath":"/category/:categoryId/discussions/:boardId/all-topics/(/:after|/:before)?","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"TkbPostPage","type":"TKB","urlPath":"/category/:categoryId/kbs/:boardId/create","__typename":"PageDescriptor"},"__typename":"PageResource"},{"lastUpdatedTime":1736942066867,"localOverride":null,"page":{"id":"GroupHubPostPage","type":"GROUP_HUB","urlPath":"/group/:groupHubId/:boardId/create","__typename":"PageDescriptor"},"__typename":"PageResource"}],"localOverride":false},"CachedAsset:text:en_US-components/context/AppContext/AppContextProvider-0":{"__typename":"CachedAsset","id":"text:en_US-components/context/AppContext/AppContextProvider-0","value":{"noCommunity":"Cannot find community","noUser":"Cannot find current user","noNode":"Cannot find node with id {nodeId}","noMessage":"Cannot find message with id {messageId}"},"localOverride":false},"CachedAsset:text:en_US-shared/client/components/common/Loading/LoadingDot-0":{"__typename":"CachedAsset","id":"text:en_US-shared/client/components/common/Loading/LoadingDot-0","value":{"title":"Loading..."},"localOverride":false},"User:user:-1":{"__typename":"User","id":"user:-1","uid":-1,"login":"anonymous","email":"","avatar":null,"rank":null,"kudosWeight":1,"registrationData":{"__typename":"RegistrationData","status":"ANONYMOUS","registrationTime":null,"confirmEmailStatus":false,"registrationAccessLevel":"VIEW","ssoRegistrationFields":[]},"ssoId":null,"profileSettings":{"__typename":"ProfileSettings","dateDisplayStyle":{"__typename":"InheritableStringSettingWithPossibleValues","key":"layout.friendly_dates_enabled","value":"true","localValue":"true","possibleValues":["true","false"]},"dateDisplayFormat":{"__typename":"InheritableStringSetting","key":"layout.format_pattern_date","value":"MM-dd-yyyy","localValue":"MM-dd-yyyy"},"language":{"__typename":"InheritableStringSettingWithPossibleValues","key":"profile.language","value":"en-US","localValue":"en","possibleValues":["en-US"]}},"deleted":false},"Theme:customTheme1":{"__typename":"Theme","id":"customTheme1"},"Category:category:101001000":{"__typename":"Category","id":"category:101001000","entityType":"CATEGORY","displayId":"101001000","nodeType":"category","depth":2,"title":"Help","shortTitle":"Help","parent":{"__ref":"Category:category:English"},"categoryPolicies":{"__typename":"CategoryPolicies","canReadNode":{"__typename":"PolicyResult","failureReason":null}}},"Category:category:top":{"__typename":"Category","id":"category:top","displayId":"top","nodeType":"category","depth":0,"title":"Top","entityType":"CATEGORY","shortTitle":"Top"},"Category:category:English":{"__typename":"Category","id":"category:English","displayId":"English","nodeType":"category","depth":1,"parent":{"__ref":"Category:category:top"},"title":"Community","entityType":"CATEGORY","shortTitle":"en","categoryPolicies":{"__typename":"CategoryPolicies","canReadNode":{"__typename":"PolicyResult","failureReason":null}}},"Forum:board:101001014":{"__typename":"Forum","id":"board:101001014","entityType":"FORUM","displayId":"101001014","nodeType":"board","depth":3,"conversationStyle":"FORUM","title":"Create, upload, and share","description":"Find help to solve issues with creating, uploading, and sharing files and folders in Dropbox. Get support and advice from the Dropbox Community.","avatar":null,"profileSettings":{"__typename":"ProfileSettings","language":null},"parent":{"__ref":"Category:category:101001000"},"ancestors":{"__typename":"CoreNodeConnection","edges":[{"__typename":"CoreNodeEdge","node":{"__ref":"Community:community:mxpez29397"}},{"__typename":"CoreNodeEdge","node":{"__ref":"Category:category:English"}},{"__typename":"CoreNodeEdge","node":{"__ref":"Category:category:101001000"}}]},"userContext":{"__typename":"NodeUserContext","canAddAttachments":false,"canUpdateNode":false,"canPostMessages":false,"isSubscribed":false},"boardPolicies":{"__typename":"BoardPolicies","canPublishArticleOnCreate":{"__typename":"PolicyResult","failureReason":{"__typename":"FailureReason","message":"error.lithium.policies.forums.policy_can_publish_on_create_workflow_action.accessDenied","key":"error.lithium.policies.forums.policy_can_publish_on_create_workflow_action.accessDenied","args":[]}},"canReadNode":{"__typename":"PolicyResult","failureReason":null}},"shortTitle":"Create, upload, and share","repliesProperties":{"__typename":"RepliesProperties","sortOrder":"PUBLISH_TIME","repliesFormat":"threaded"},"topicsCount":5171,"messageActivity":{"__typename":"MessageActivity","corePropertyChangeTime":"2025-01-20T10:28:26.915-08:00"},"forumPolicies":{"__typename":"ForumPolicies","canReadNode":{"__typename":"PolicyResult","failureReason":null}},"eventPath":"category:101001000/category:English/community:mxpez29397board:101001014/","tagProperties":{"__typename":"TagNodeProperties","tagsEnabled":{"__typename":"PolicyResult","failureReason":null}},"requireTags":true,"tagType":"PRESET_ONLY"},"Rank:rank:44":{"__typename":"Rank","id":"rank:44","position":27,"name":"Helpful | Level 5","color":"333333","icon":null,"rankStyle":"TEXT"},"User:user:35025":{"__typename":"User","id":"user:35025","uid":35025,"login":"David S.118","deleted":false,"avatar":{"__typename":"UserAvatar","url":"https://www.dropboxforum.com/t5/s/mxpez29397/m_assets/avatars/default/avatar-4.svg"},"rank":{"__ref":"Rank:rank:44"},"email":"","messagesCount":3,"biography":null,"topicsCount":2,"kudosReceivedCount":0,"kudosGivenCount":1,"kudosWeight":1,"registrationData":{"__typename":"RegistrationData","status":null,"registrationTime":"2015-06-24T18:37:00.000-07:00","confirmEmailStatus":null,"registrationAccessLevel":null,"ssoRegistrationFields":[]},"followersCount":null,"solutionsCount":0,"ssoId":null,"entityType":"USER","eventPath":"community:mxpez29397/user:35025"},"ForumTopicMessage:message:680736":{"__typename":"ForumTopicMessage","uid":680736,"subject":"How can a script or app get a shareable Dropbox link?","id":"message:680736","revisionNum":2,"repliesCount":3,"author":{"__ref":"User:user:35025"},"depth":0,"hasGivenKudo":false,"board":{"__ref":"Forum:board:101001014"},"conversation":{"__ref":"Conversation:conversation:680736"},"readOnly":true,"editFrozen":false,"moderationData":{"__ref":"ModerationData:moderation_data:680736"},"body":"
I'm trying to automate a task I've been doing for a while that's taking way too much time, and it requires me to send a sharable link to someone for some files in my Dropbox. So I have a script I've written but ... where I'd normally right-click to get a sharable link for a file, how can I get such a link within the script? I know the file locally on my machine, but how can I get a sharable Dropbox link? Can I use the Dropbox API for that? or is there a simpler way?
","body@stringLength":"477","rawBody":"
I'm trying to automate a task I've been doing for a while that's taking way too much time, and it requires me to send a sharable link to someone for some files in my Dropbox. So I have a script I've written but ... where I'd normally right-click to get a sharable link for a file, how can I get such a link within the script? I know the file locally on my machine, but how can I get a sharable Dropbox link? Can I use the Dropbox API for that? or is there a simpler way?
You can take a look on thread' post here for an idea how that can be done. 😉
Hope this helps.
","body@stripHtml({\"removeProcessingText\":false,\"removeSpoilerMarkup\":false,\"removeTocMarkup\":false,\"truncateLength\":200})@stringLength":"114","kudosSumWeight":0,"postTime":"2023-04-30T09:46:53.729-07:00","lastPublishTime":"2023-04-30T09:46:53.729-07:00","metrics":{"__typename":"MessageMetrics","views":1707},"visibilityScope":"PUBLIC","placeholder":false,"originalMessageForPlaceholder":null,"isEscalated":null,"solution":false,"entityType":"FORUM_REPLY","eventPath":"category:101001000/category:English/community:mxpez29397board:101001014/message:680736/message:680739","replies":{"__typename":"MessageConnection","pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null},"edges":[{"__typename":"MessageEdge","cursor":"MjQuMTF8Mi4xfGl8M3w1MjoxfGludCw2ODA4MjEsNjgwODIx","node":{"__ref":"ForumReplyMessage:message:680821"}}]},"customFields":[],"attachments":{"__typename":"AttachmentConnection","edges":[],"pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null}}},"ModerationData:moderation_data:680821":{"__typename":"ModerationData","id":"moderation_data:680821","status":"APPROVED","rejectReason":null,"isReportedAbuse":false,"rejectUser":null,"rejectTime":null,"rejectActorType":"member"},"ForumReplyMessage:message:680821":{"__typename":"ForumReplyMessage","uid":680821,"id":"message:680821","revisionNum":1,"author":{"__ref":"User:user:35025"},"readOnly":true,"repliesCount":1,"depth":2,"hasGivenKudo":false,"subscribed":false,"board":{"__ref":"Forum:board:101001014"},"parent":{"__ref":"ForumReplyMessage:message:680739"},"conversation":{"__ref":"Conversation:conversation:680736"},"subject":"Re: How can a script or app get a shareable Dropbox link?","moderationData":{"__ref":"ModerationData:moderation_data:680821"},"body":"
Thanks. I'm not sure what language that example script is in.
I need this to run in Windows.
After looking through a bunch of related posts, it looks like there might be a command-line tool that I can run in Windows that does this.
","body@stripHtml({\"removeProcessingText\":false,\"removeSpoilerMarkup\":false,\"removeTocMarkup\":false,\"truncateLength\":200})@stringLength":"218","kudosSumWeight":0,"postTime":"2023-04-30T23:14:37.103-07:00","lastPublishTime":"2023-04-30T23:14:37.103-07:00","metrics":{"__typename":"MessageMetrics","views":1695},"visibilityScope":"PUBLIC","placeholder":false,"originalMessageForPlaceholder":null,"isEscalated":null,"solution":false,"entityType":"FORUM_REPLY","eventPath":"category:101001000/category:English/community:mxpez29397board:101001014/message:680736/message:680821","replies":{"__typename":"MessageConnection","pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null},"edges":[{"__typename":"MessageEdge","cursor":"MjQuMTF8Mi4xfGl8MXw1MjoxfGludCw2ODA5MjgsNjgwOTI4","node":{"__ref":"ForumReplyMessage:message:680928"}}]},"customFields":[],"attachments":{"__typename":"AttachmentConnection","edges":[],"pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null}}},"ModerationData:moderation_data:680928":{"__typename":"ModerationData","id":"moderation_data:680928","status":"APPROVED","rejectReason":null,"isReportedAbuse":false,"rejectUser":null,"rejectTime":null,"rejectActorType":"member"},"ForumReplyMessage:message:680928":{"__typename":"ForumReplyMessage","author":{"__ref":"User:user:422790"},"id":"message:680928","revisionNum":1,"uid":680928,"depth":3,"hasGivenKudo":false,"subscribed":false,"board":{"__ref":"Forum:board:101001014"},"parent":{"__ref":"ForumReplyMessage:message:680821"},"conversation":{"__ref":"Conversation:conversation:680736"},"subject":"Re: How can a script or app get a shareable Dropbox link?","moderationData":{"__ref":"ModerationData:moderation_data:680928"},"body":"
Hah..😯 You said \"I have a script I've written but...\", but seems you don't have too much experience, since can distinguish one of the most popular scripting languages - Python. Some parts of the official Dropbox application is implemented in the same language also. Even more, it's mentioned in the script header line. Didn't you read it? Anyway... it's my wrong assumption; I'll try to be more descriptive.
Oh... The script, I linked to, targets Mac and Linux only; on Windows can run but not in the same form. I just made some tweaks to let it work on Windows. Since it's Python script, you have to have Python interpreter installed, if you haven't yet, to be able run it. So first download and install the interpreter from here. Make sure you have selected all accessibility on install time:
Once the interpreter installed you may need some additional packages available, so make sure they are there. Execute following commands in terminal window:
Now you have everything needed to run the script that let you get Dropbox links. The following is updated script version, working on Windows too:
#!/usr/bin/python3\n###############################################################################\n# Script receiving Dropbox links based on referred local files/folders\n# --------------------------------------------------------------------\n# Every target file/folder is passed as argument to the script. Resulted links\n# are passed in the same sequence one per line to standard output (incorrect\n# are skipped).\n# Two preparation steps are needed:\n# 1. Register a Dropbox application and put the application key as value of\n# APPLICATION_KEY global variable.\n# 2. Register the used REDIRECT_URI in the application just created in\n# previous step. With host 'localhost' and port 8080, the redirect URL\n# that has to be registered is \"http://localhost:8080/\", for instance.\n# Next, just make it executable (if needed), using:\n# $ chmod a+x get_dropbox_link\n# ... and put it in a place visible for execution in your system (somewhere in\n# folders pointed by $PATH environment variable). On first run you will be\n# invited to link your script to your Dropbox account. To work correct local\n# Dropbox application and this script have to be link to the same account!\n# Verified on Dropbox v172.4.7555\n# Author: Здравко\n# www.dropboxforum.com/t5/user/viewprofilepage/user-id/422790\n###############################################################################\n\nfrom dropbox import Dropbox, DropboxOAuth2Flow\nfrom dropbox.exceptions import ApiError\nfrom dropbox.oauth import NotApprovedException\nimport json\nfrom pathlib import Path\nfrom datetime import datetime\nfrom os import sep, name, makedirs\nfrom sys import exit\nimport logging\nfrom platformdirs import user_config_path\n\n# Place to save current configuration\nCONFIG_JSON=user_config_path('get_dropbox_link') / 'cred.json'\n\n# Take a look on your application in https://www.dropbox.com/developers/apps\nAPPLICATION_KEY='PUT YOUR KEY HERE'\n\nURI_HOST='localhost'\nURI_PORT=8080\n# URI should be registered in the application redirect URIs list!!!\nREDIRECT_URI=f\"http://{URI_HOST}:{URI_PORT}/\"\n\nsuccess_response = \"End of authentication flow. 😉 Your can get a link!\"\ncancel_response = \"🤷 You have denied your application's work. 😕\"\nerror_response = \"😈 You got an error: \"\n\nclass ApplicationConfig:\n def __init__(self, conf_path=CONFIG_JSON):\n self.conf_path=Path(conf_path).expanduser()\n self.conf=None\n self.client=None\n self.access_token=None\n self.access_token_expiresat=None\n self.refresh_token=None\n makedirs(self.conf_path.parent, exist_ok=True)\n if self.conf_path.is_file():\n try:\n with self.conf_path.open() as fconf:\n self.conf=json.load(fconf)\n self.access_token = self.conf['access_token']\n self.access_token_expiresat = datetime.fromtimestamp(\n self.conf['access_token_expiresat'])\n self.refresh_token = self.conf['refresh_token']\n except Exception:\n self.conf_path.unlink(True)\n self.conf=None\n def __del__(self):\n \"Checks for something changed (new access token) and dumps it when there is\"\n if (self.client is not None and\n self.client._oauth2_access_token_expiration >\n self.access_token_expiresat):\n self.conf['access_token'] = self.client._oauth2_access_token\n self.conf['access_token_expiresat'] = (\n self.client._oauth2_access_token_expiration.timestamp())\n self.conf['refresh_token'] = self.client._oauth2_refresh_token\n with self.conf_path.open(mode='w') as fconf:\n json.dump(self.conf, fconf)\n def getClient(self):\n \"Gets Dropbox client object. Performs OAuth flow if needed.\"\n if self.conf is None:\n self.client=None\n import webbrowser\n from http.server import HTTPServer, BaseHTTPRequestHandler\n dbxAuth=DropboxOAuth2Flow(APPLICATION_KEY, REDIRECT_URI, {},\n 'dropbox-auth-csrf-token', token_access_type='offline', use_pkce=True)\n webbrowser.open(dbxAuth.start())\n conf=None\n conf_path = self.conf_path\n class Handler(BaseHTTPRequestHandler):\n response_success = success_response.encode()\n response_cancel = cancel_response.encode()\n response_error = error_response.encode()\n def do_GET(self):\n nonlocal dbxAuth, conf\n from urllib.parse import urlparse, parse_qs\n query = parse_qs(urlparse(self.path).query)\n for r in query.keys():\n query[r] = query[r][0]\n self.send_response(200)\n self.send_header(\"content-type\", \"text/plain;charset=UTF-8\")\n try:\n oauthRes = dbxAuth.finish(query)\n conf={'access_token': oauthRes.access_token,\n 'access_token_expiresat': oauthRes.expires_at.timestamp(),\n 'refresh_token': oauthRes.refresh_token}\n with conf_path.open(mode='w') as fconf:\n json.dump(conf, fconf)\n except NotApprovedException:\n conf={}\n self.send_header(\"content-length\", f\"{len(Handler.response_cancel)}\")\n self.end_headers()\n self.wfile.write(Handler.response_cancel)\n self.wfile.flush()\n return\n except Exception as e:\n conf={}\n r = Handler.response_error + str(e).encode()\n self.send_header(\"content-length\", f\"{len(r)}\")\n self.end_headers()\n self.wfile.write(r)\n self.wfile.flush()\n return\n self.send_header(\"content-length\", f\"{len(Handler.response_success)}\")\n self.end_headers()\n self.wfile.write(Handler.response_success)\n self.wfile.flush()\n httpd=HTTPServer((URI_HOST, URI_PORT), Handler)\n while conf is None:\n httpd.handle_request()\n httpd.server_close()\n del httpd\n if 'refresh_token' not in conf:\n raise RuntimeError(\"Cannot process because missing authentication\")\n self.conf = conf\n self.access_token = self.conf['access_token']\n self.access_token_expiresat = datetime.fromtimestamp(\n self.conf['access_token_expiresat'])\n self.refresh_token = self.conf['refresh_token']\n # Makes sure there is cached client object.\n if self.client is None:\n self.client=Dropbox(self.access_token,\n oauth2_refresh_token=self.refresh_token,\n oauth2_access_token_expiration=self.access_token_expiresat,\n app_key=APPLICATION_KEY)\n return self.client\n\nclass PathMapper:\n def __init__(self):\n if name == 'nt':\n dbx_info = user_config_path() / 'Dropbox' / 'info.json'\n else:\n dbx_info = Path('~/.dropbox/info.json').expanduser()\n if not dbx_info.is_file():\n raise RuntimeError(\"Missing Dropbox application information\")\n with dbx_info.open() as finfo:\n # Only personal accounts are supported by now - group accounts need\n # additional namespace handling (just changing 'personal' is not enough).\n # Somebody else may make some exercises. \n self.dbx_path = json.load(finfo)['personal']['path']\n def __contains__(self, path):\n path = str(Path(path).expanduser().absolute())\n return ((len(path) == len(self.dbx_path) and path == self.dbx_path) or\n (len(path) > len(self.dbx_path) and path[len(self.dbx_path)] == sep\n and path[:len(self.dbx_path)] == self.dbx_path))\n def __getitem__(self, path):\n path = str(Path(path).expanduser().absolute())\n if ((len(path) == len(self.dbx_path) and path == self.dbx_path) or\n (len(path) > len(self.dbx_path) and path[len(self.dbx_path)] == sep\n and path[:len(self.dbx_path)] == self.dbx_path)):\n return Path(path[len(self.dbx_path):]).as_posix()\n\ndef main():\n import argparse\n dbxPathMap = PathMapper()\n parser = argparse.ArgumentParser(description=\"Fetch Dropbox URL for path\")\n parser.add_argument(\"paths\", type=str, nargs=\"+\", help=\"paths to files\")\n parser.add_argument(\"--verbose\", \"-v\", action=\"store_true\",\n help=\"toggle verbose mode\")\n args = parser.parse_args()\n del parser\n \n if args.verbose:\n logging.basicConfig(level=logging.DEBUG)\n \n conf = ApplicationConfig()\n dbx = conf.getClient()\n \n for path in args.paths:\n if path not in dbxPathMap:\n logging.error(f\"Passed path '{path}' is not part of the Dropbox driectory tree\")\n continue\n dbx_path = dbxPathMap[path]\n if len(dbx_path) == 0:\n logging.error(\"Dropbox folder itself cannot be pointed by link\")\n continue\n logging.debug(f\"Processing local file '{path}' with Dropbox path '{dbx_path}'\")\n try:\n metadata = dbx.sharing_create_shared_link_with_settings(dbx_path)\n except ApiError as e:\n er = e.error\n if not er.is_shared_link_already_exists():\n raise\n er = er.get_shared_link_already_exists()\n if not er.is_metadata():\n raise\n metadata = er.get_metadata()\n print(metadata.url)\n\nif __name__ == \"__main__\":\n try:\n main()\n except Exception as e:\n logging.error(f\"Unexpected error: {e}\")\n exit(1)
Save above script in a file named \"get_dropbox_link\" on place convenient for you. Since this script uses Dropbox API, you need to register your application here. Select \"Full Dropbox\" as access type, since you will need access to files in entire account, not only application specific files. Make sure \"sharing.write\" is selected scope in your application permission (to be able create and get shared links). In section Redirect URIs, ensure URL \"http://localhost:8080/\" is present (add it as needed). On the same page is field named App key; copy the value/key shown there to corresponding place in the script (near beginning - it's the only redaction you have to make). Now you're almost ready. Type in the terminal something like:
py <exec path to>\\get_dropbox_link <path into Dropbox>
Here <exec path to> is optional path to the place you put the script on. You may need to use such explicit path when the script is not directly visible from the place you're calling from. <path into Dropbox> is path to file/folder, residing within your local Dropbox folder, you want to get shared link to. That's it. 😉 You can ether extend this script and/or call it from any other script (doesn't have to be Python script; can be any other script).
Good luck.
","body@stripHtml({\"removeProcessingText\":false,\"removeSpoilerMarkup\":false,\"removeTocMarkup\":false,\"truncateLength\":200})@stringLength":"213","kudosSumWeight":1,"repliesCount":0,"postTime":"2023-05-01T07:26:23.633-07:00","lastPublishTime":"2023-05-01T07:26:23.633-07:00","metrics":{"__typename":"MessageMetrics","views":1629},"visibilityScope":"PUBLIC","placeholder":false,"originalMessageForPlaceholder":null,"isEscalated":null,"solution":false,"entityType":"FORUM_REPLY","eventPath":"category:101001000/category:English/community:mxpez29397board:101001014/message:680736/message:680928","customFields":[],"attachments":{"__typename":"AttachmentConnection","edges":[],"pageInfo":{"__typename":"PageInfo","hasNextPage":false,"endCursor":null,"hasPreviousPage":false,"startCursor":null}}},"CachedAsset:text:en_US-components/community/NavbarDropdownToggle-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-components/community/NavbarDropdownToggle-1737382617494","value":{"ariaLabelClosed":"Press the down arrow to open the menu"},"localOverride":false},"CachedAsset:text:en_US-components/messages/EscalatedMessageBanner-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-components/messages/EscalatedMessageBanner-1737382617494","value":{"escalationMessage":"Escalated to Salesforce by {username} on {date}","viewDetails":"View Details","modalTitle":"Case Details","escalatedBy":"Escalated by: ","escalatedOn":"Escalated on: ","caseNumber":"Case Number: ","status":"Status: ","lastUpdateDate":"Last Update: ","automaticEscalation":"automatic escalation","anonymous":"Anonymous"},"localOverride":false},"CachedAsset:text:en_US-components/users/UserLink-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-components/users/UserLink-1737382617494","value":{"authorName":"View Profile: {author}","anonymous":"Anonymous"},"localOverride":false},"CachedAsset:text:en_US-shared/client/components/users/UserRank-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-shared/client/components/users/UserRank-1737382617494","value":{"rankName":"{rankName}","userRank":"Author rank {rankName}"},"localOverride":false},"CachedAsset:text:en_US-components/messages/MessageTime-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-components/messages/MessageTime-1737382617494","value":{"postTime":"Published: {time}","lastPublishTime":"Last Update: {time}","conversation.lastPostingActivityTime":"Last posting activity time: {time}","conversation.lastPostTime":"Last post time: {time}","moderationData.rejectTime":"Rejected time: {time}"},"localOverride":false},"CachedAsset:text:en_US-components/messages/MessageSubject-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-components/messages/MessageSubject-1737382617494","value":{"noSubject":"(no subject)"},"localOverride":false},"CachedAsset:text:en_US-components/messages/MessageBody-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-components/messages/MessageBody-1737382617494","value":{"showMessageBody":"Show More","mentionsErrorTitle":"{mentionsType, select, board {Board} user {User} message {Message} other {}} No Longer Available","mentionsErrorMessage":"The {mentionsType} you are trying to view has been removed from the community.","videoProcessing":"Video is being processed. Please try again in a few minutes.","bannerTitle":"Video provider requires cookies to play the video. Accept to continue or {url} it directly on the provider's site.","buttonTitle":"Accept","urlText":"watch"},"localOverride":false},"CachedAsset:text:en_US-components/messages/MessageCustomFields-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-components/messages/MessageCustomFields-1737382617494","value":{"CustomField.default.label":"Value of {name}"},"localOverride":false},"CachedAsset:text:en_US-components/messages/MessageReplyButton-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-components/messages/MessageReplyButton-1737382617494","value":{"repliesCount":"{count}","title":"Reply","title@board:BLOG@message:root":"Comment","title@board:TKB@message:root":"Comment","title@board:IDEA@message:root":"Comment","title@board:OCCASION@message:root":"Comment"},"localOverride":false},"CachedAsset:text:en_US-components/messages/AcceptedSolutionButton-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-components/messages/AcceptedSolutionButton-1737382617494","value":{"accept":"Mark as Solution","accepted":"Marked as Solution","errorHeader":"Error!","errorAdd":"There was an error marking as solution.","errorRemove":"There was an error unmarking as solution.","solved":"Solved"},"localOverride":false},"CachedAsset:text:en_US-shared/client/components/common/Pager/PagerLoadMore-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-shared/client/components/common/Pager/PagerLoadMore-1737382617494","value":{"loadMore":"Show More"},"localOverride":false},"CachedAsset:text:en_US-components/nodes/NodeView/NodeViewCard-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-components/nodes/NodeView/NodeViewCard-1737382617494","value":{"title":"{nodeTitle} ","creationDate":"Created: {creationDate}","ownedBy":"Owned by: {owners}{text}","showOwnerListText":", and {ownersCount} more","unreadCount":"{count} unread","nodeViewDrawerBtn":"Node view drawer for {place}","drawerActionTooltip":"Show category children"},"localOverride":false},"CachedAsset:text:en_US-components/messages/MessageView/MessageViewInline-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-components/messages/MessageView/MessageViewInline-1737382617494","value":{"bylineAuthor":"{bylineAuthor}","bylineBoard":"{bylineBoard}","anonymous":"Anonymous","place":"Place {bylineBoard}","gotoParent":"Go to parent {name}"},"localOverride":false},"CachedAsset:text:en_US-shared/client/components/users/UserAvatar-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-shared/client/components/users/UserAvatar-1737382617494","value":{"altText":"{login}'s avatar","altTextGeneric":"User's avatar"},"localOverride":false},"CachedAsset:text:en_US-shared/client/components/ranks/UserRankLabel-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-shared/client/components/ranks/UserRankLabel-1737382617494","value":{"altTitle":"Icon for {rankName} rank"},"localOverride":false},"CachedAsset:text:en_US-shared/client/components/nodes/NodeAvatar-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-shared/client/components/nodes/NodeAvatar-1737382617494","value":{"altTitle":"Node avatar for {nodeTitle}"},"localOverride":false},"CachedAsset:text:en_US-shared/client/components/nodes/NodeDescription-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-shared/client/components/nodes/NodeDescription-1737382617494","value":{"description":"{description}"},"localOverride":false},"CachedAsset:text:en_US-components/tags/TagView/TagViewChip-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-components/tags/TagView/TagViewChip-1737382617494","value":{"tagLabelName":"Tag name {tagName}"},"localOverride":false},"CachedAsset:text:en_US-shared/client/components/nodes/NodeIcon-1737382617494":{"__typename":"CachedAsset","id":"text:en_US-shared/client/components/nodes/NodeIcon-1737382617494","value":{"contentType":"Content Type {style, select, FORUM {Forum} BLOG {Blog} TKB {Knowledge Base} IDEA {Ideas} OCCASION {Events} other {}} icon"},"localOverride":false}}}},"page":"/forums/ForumMessagePage/ForumMessagePage","query":{"boardId":"101001014","messageSubject":"how-can-a-script-or-app-get-a-shareable-dropbox-link","messageId":"680736"},"buildId":"OKtI0OLKuXmERTJKBVqYX","runtimeConfig":{"buildInformationVisible":false,"logLevelApp":"info","logLevelMetrics":"info","openTelemetryClientEnabled":false,"openTelemetryConfigName":"dropbox","openTelemetryServiceVersion":"24.11.0","openTelemetryUniverse":"prod","openTelemetryCollector":"http://localhost:4318","openTelemetryRouteChangeAllowedTime":"5000","apolloDevToolsEnabled":false},"isFallback":false,"isExperimentalCompile":false,"dynamicIds":["./components/seo/QAPageSchema/QAPageSchema.tsx","./components/community/Navbar/NavbarWidget.tsx","./components/community/Breadcrumb/BreadcrumbWidget.tsx","./components/customComponent/CustomComponent/CustomComponent.tsx","./components/messages/TopicWithThreadedReplyListWidget/TopicWithThreadedReplyListWidget.tsx","./components/nodes/NodeActionButtonWidget/NodeActionButtonWidget.tsx","./components/nodes/NodeInformationWidget/NodeInformationWidget.tsx","./components/messages/RelatedContentWidget/RelatedContentWidget.tsx","./components/messages/MessageListForNodeByRecentActivityWidget/MessageListForNodeByRecentActivityWidget.tsx","./components/messages/MessageView/MessageViewStandard/MessageViewStandard.tsx","./components/messages/ThreadedReplyList/ThreadedReplyList.tsx","../shared/client/components/common/List/UnstyledList/UnstyledList.tsx","./components/messages/MessageView/MessageView.tsx","../shared/client/components/common/Pager/PagerLoadMore/PagerLoadMore.tsx","./components/nodes/NodeView/NodeView.tsx","./components/nodes/NodeView/NodeViewCard/NodeViewCard.tsx","./components/messages/MessageView/MessageViewInline/MessageViewInline.tsx","../shared/client/components/common/List/UnwrappedList/UnwrappedList.tsx","./components/tags/TagView/TagView.tsx","./components/tags/TagView/TagViewChip/TagViewChip.tsx"],"appGip":true,"scriptLoader":[]}