We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
af11
3 years agoExplorer | Level 4
dropbox.exceptions.BadInputError
I am trying to connect an app to my company dropbox account.
Here is the code:
from hashlib import sha256
import hmac
import json
import os
import threading
import urllib.parse
from dotenv i...
- 3 years ago
The DropboxTeam.as_admin method returns a Dropbox object; it doesn't modify the existing DropboxTeam object (dbx in your latest snippet here). So, the code in your latest snippet won't allow you to call files_list_folder on that 'dbx' object. You should save the returned Dropbox object and use that instead.
Greg-DB
Dropbox Staff
This error message in particular is referring to specifying what account on the Business team to operate on behalf of. For reference, when using any "team scopes", the resulting access token is connected to an entire Dropbox Business team, not an individual account. So, when using a team-scoped access token to access user-specific endpoints, such as /2/users/get_current_account (users_get_current_account in the Python SDK), you will need to specify which member of the team you want to operate on behalf of.
To do this, you'd need to specify the 'Dropbox-API-Select-User' header (or 'Dropbox-API-Select-Admin' as needed/desired). The value should be the team_member_id
for whichever member you wish to act on behalf of. In the Python SDK, you can set that header using the DropboxTeam.as_user
method (or DropboxTeam.as_admin
).
Alternatively, if you just want to connect to a particular account, you can disable any team scopes and get a new access token without them. The access token without the team scopes will be specific to the particular account (Business or not) and so will not require the additional header. You can find more information on scopes in the OAuth Guide. If you don't need to call any team endpoints (e.g., if you just need to call individual endpoints, such as /2/users/get_current_account (users_get_current_account in the Python SDK)), I recommend this solution instead for simplicity and security.
af11
3 years agoExplorer | Level 4
Thank you.
I did that now:
id = os.environ.get('USER_ID')
dbx = DropboxTeam(token)
dbx.as_admin(id)
But now, I can't do all the methods that I did in the Dropbox class above, for example files_list_folder().
How can I be able to do these methods?
- Greg-DB3 years agoDropbox Staff
The DropboxTeam.as_admin method returns a Dropbox object; it doesn't modify the existing DropboxTeam object (dbx in your latest snippet here). So, the code in your latest snippet won't allow you to call files_list_folder on that 'dbx' object. You should save the returned Dropbox object and use that instead.
- Здравко3 years agoLegendary | Level 20
af11 wrote:...
I did that now:
id = os.environ.get('USER_ID') dbx = DropboxTeam(token) dbx.as_admin(id)
But now, I can't do all the methods that I did in the Dropbox class above, for example files_list_folder().
...
Hi af11,
Hmm... 🤔 Where you are keeping Dropbox object resulting from the last call in your code? ... Or maybe, by mistake, you are trying call Dropbox methods on DropboxTeam object?! 🙂 Be more careful. Take a look once back on the documentation provided by Greg-DB above (note what 'as_admin' returns) and try again. 😉
Hope this helps.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 12 months agoIf 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!