actAsUser does not expose same method signature as Dropbox constructor
See original GitHub issueIf my understanding is correct, DropboxTeam#actAsUser
(using a hashtag here to signify that actAsUser
is an instance method and not a static method) returns an instance of Dropbox
with selectUser
set as the userId
that was passed into actAsUser
. Using actAsUser
does not allow me to do something like the following:
require('isomorphic-fetch');
const dropbox = require('dropbox');
const dbxTeam = new dropbox.DropboxTeam({ accessToken: 'myAccessToken' });
const memberInfo = await dbxTeam.teamMembersGetInfo({
members: [{
'.tag': 'email',
email: 'someAdminEmailAddress'
}]
});
const userId = memberInfo[0].profile.team_member_id;
const userDbx = dbxTeam.actAsUser(userId)
const createdFolder = await userDbx.filesCreateFolder({ path: `ns:${namespaceId}/some/dir` });
console.log(createdFolder);
because it returns the following error, regardless of the member being a team admin:
error: { error:
{ error_summary: 'path/no_write_permission/',
error: { '.tag': 'path', path: [Object] } },
response:
Body {
url: 'https://api.dropboxapi.com/2/files/create_folder',
status: 409,
statusText: 'Conflict',
headers: Headers { _headers: [Object] },
ok: false,
body:
PassThrough {
_readableState: [Object],
readable: false,
domain: null,
_events: [Object],
_eventsCount: 4,
_maxListeners: undefined,
_writableState: [Object],
writable: false,
allowHalfOpen: true,
_transformState: [Object] },
bodyUsed: true,
size: 0,
timeout: 0,
_raw:
[ <Buffer 7b 22 65 72 72 6f 72 5f 73 75 6d 6d 61 72 79 22 3a 20 22 70 61 74 68 2f 6e 6f 5f 77 72 69 74 65 5f 70 65 72 6d 69 73 73 69 6f 6e 2f 22 2c 20 22 65 72 ... > ],
_abort: false,
_bytes: 114 },
status: 409 }
instead, i have to do:
require('isomorphic-fetch');
const dropbox = require('dropbox');
const dbxTeam = new dropbox.DropboxTeam({ accessToken: 'myAccessToken' });
const memberInfo = await dbxTeam.teamMembersGetInfo({
members: [{
'.tag': 'email',
email: 'someAdminEmailAddress'
}]
});
const userId = memberInfo[0].profile.team_member_id;
const userDbx = new dropbox.Dropbox({ accessToken: 'myAcessToken', selectAdmin: userId });
const createdFolder = await userDbx.filesCreateFolder({ path: `ns:${namespaceId}/some/dir` });
console.log(createdFolder);
The problem here seems to be that selectAdmin
cannot be set when using actAsUser
. This should be easily fixable by changing the expected argument for actAsUser
to be the same as what’s expected for the Dropbox
constructor.
Further, selectAdmin
is not documented anywhere. The only two options i had in order to figure out how to even create folders within a team space were:
- Contact customer support
- Read through the source code myself.
I’ve found the 2nd option to be far better, though slightly painful, than reading the documentation you all have available because it seems to be vastly outdated. I’ve had nothing but problems while using the dropbox api. I suppose i expected far more from a company of this stature. Inconsistent method names such as teamTeamFolderCreate
versus filesCreateFolder
versus teamNamespacesList
is tolerable but outdated/incorrect documentation, examples that don’t work and hidden features is just not something i expected from dropbox.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:5 (4 by maintainers)
Top GitHub Comments
@greg-db Thanks for the prompt response as well as for the info regarding the mutual exclusivity of
selectUser
andselectAdmin
. I do however think it should be possible toselectAdmin
when callingDropboxTeam.actAsUser
or maybe exposing another method calledDropboxTeam.actAsAdmin
. Not adding the ability to useselectAdmin
withactAsUser
sort of draws a fork in the road regarding what you can do with aDropbox
instance versus whatactAsUser
returns which seems weird becauseactAsUser
is really just a convenience method that returns an instance ofDropbox
This should be updated now as of the latest version. You can find more information in the updated documentation and this upgrading guide.