We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
Kevin B.36
2 months agoCollaborator | Level 9
Find DBID on Local PC
Application Affected My own app Device Windows 11 VM Operating System/Browser (if using the web) Windows 11 Dropbox App Version (if using the app) Latest Question or Issue We have an app tha...
- 24 days ago
Hi again Kevin B.36,
I tried to reproduce your issue, but honestly unsuccessful.
About your speculations: Once setup correctly, Dropbox application doesn't change that file if you haven't forced it (link/unlink account), so "before the Dropbox app has initialized it" in context of just starting - impossible in fact. There is something else possible though. Since that file becomes locked temporary (for short time) at Dropbox application stat moment, your application may be trying read the file at the same time without set enough timeout. On boot time, this lock time may be longer that the default timeout of the sqlite3 library you're using. You may try set explicitly longer connect timeout. It's good idea to trace possible changes in this file and update your application status if/when need (not just to fetch the info at beginning - user may change account at any time) or to check what's there exactly when need at any time your application has to check it (so avoiding keep any status about the account of Dropbox application together with possible hidden bugs).
I used following simple script to check what's going on:
#!/bin/python3 ############################################################################### # Checking for matching third party application account and local Dropbox # application account. # ----------------------------------------------------------------------------- # Author: Здравко # www.dropboxforum.com/t5/user/viewprofilepage/user-id/422790 ############################################################################### from dropbox import Dropbox from pathlib import Path from sqlite3 import connect, OperationalError from tkinter import messagebox # Take a look on your application in https://www.dropbox.com/developers/apps APPLICATION_KEY='PUT YOUR KEY HERE' APPLICATION_SECRET=None # Left None if PKCE is in use or set the actual secret. # Fetch the refresh token used in your main application or create such by hand # (take a look here: # https://www.dropboxforum.com/discussions/101000014/issue-in-generating-access-token/592667/replies/592921 # for instance). REFRESH_TOKEN='PUT YOUR TOKEN HERE' APEX_PATH='PUT YOUR apex.sqlite3 PATH HERE' client=Dropbox(oauth2_refresh_token=REFRESH_TOKEN, app_key=APPLICATION_KEY, app_secret=APPLICATION_SECRET) userInfo=client.users_get_current_account() dbid=userInfo.account_id email=userInfo.email apex=Path(APEX_PATH).expanduser().absolute() try: con = connect(f"file:{apex}?mode=ro", uri=True, timeout=50.0) except OperationalError as e: messagebox.showerror('Check Account', "Local Dropbox application is not yet installed or " f"it is not completely configured!\n\n{e}"); exit(1) try: blobs=list(row[0] for row in con.execute("SELECT value FROM apex_stormcrow")) except OperationalError as e: messagebox.showerror('Check Account', f"Local Dropbox application seems not yet completely configured!\n\n{e}"); con.close() exit(1) con.close() def getDbId(rawData): i=rawData.find(b'dbid:') length=rawData[i-1] return rawData[i:i+length].decode() localDbIds=list(getDbId(blob) for blob in blobs if blob.find(b'dbid:') > 0) if len(localDbIds) == 0: messagebox.showerror('Check Account', "Local Dropbox application is not yet completely configured!\n\n" "No any IDs found."); exit(1) if localDbIds.count(dbid) == 1: messagebox.showinfo('Check Account', "Found local Dropbox application link " "to current third party application account:\n\n" f"account id: {dbid}\n" f"email: {email}"); else: messagebox.showinfo('Check Account', "Current third party application account:\n\n" f"account id: {dbid}\n" f"email: {email}\n\n" "cannot be found in local Dropbox application link(s):\n\n" f"{localDbIds}")Everything works all the time correctly for me. You may try it simultaneous in time of your application test to see possible differences and feed your further debugging. Post strange results of above script if you decide to test it and something suspicious comes up.
All the best!
Kevin B.36
29 days agoCollaborator | Level 9
Hi Nancy,
Yes you have misunderstood.
This is for Windows: In my app (so this needs to be done programatically), I can be signed in on the Dropbox.com website as userA, BUT the app could be signed in as User B. When I run my app it displays the ALLOW window if Im already signed in to WEB Dropbox. My app then goes barrelling along with the local Dropbox credentials and sees the mismatch and objects. Yes, it is possible to be logged into Account A (which the API calls will return details of) and be signed into Account B using the local APP.
I can get the web DBID using the API easy enough. I need to get the local PC Account's DBID. I have found a file apex.sqlite3 here (which we can parse and extract the local PC DBID):
C:\Users\USERNAME\AppData\Local\Dropbox\apex.sqlite3
But this file is not always there (I'm not sure of the rules associated with its existence), but I do know at times when we install our Windows APP, there is no apex.sqlite3 file. There is an info.json file that has some details, but not the email address (which we could also use to differentiate) or the DBID.
So my question is: What is the simplest way to get the account details (email/DBID) of the local (Not Web/API) of the Dropbox Account?
Здравко
28 days agoLegendary | Level 20
Kevin B.36, when you say "I do know at times when we install our Windows APP, there is no apex.sqlite3 file", can you clarify when such a situation happens? (some steps to reproduce)
As far as I know only possible case would be when Dropbox application has never been installed at that point or not yet running (linked to some account). Did you see some other situation(s)? If so, can you share?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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, Facebook or Instagram.
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!