question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

actAsUser does not expose same method signature as Dropbox constructor

See original GitHub issue

If 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:

  1. Contact customer support
  2. 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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mistermoecommented, Feb 21, 2018

@greg-db Thanks for the prompt response as well as for the info regarding the mutual exclusivity of selectUser and selectAdmin. I do however think it should be possible to selectAdmin when calling DropboxTeam.actAsUseror maybe exposing another method called DropboxTeam.actAsAdmin. Not adding the ability to use selectAdmin with actAsUser sort of draws a fork in the road regarding what you can do with a Dropbox instance versus what actAsUser returns which seems weird because actAsUser is really just a convenience method that returns an instance of Dropbox

0reactions
greg-dbcommented, Sep 28, 2020

This should be updated now as of the latest version. You can find more information in the updated documentation and this upgrading guide.

Read more comments on GitHub >

github_iconTop Results From Across the Web

actAsUser does not expose same method signature as Dropbox ...
If my understanding is correct, DropboxTeam#actAsUser (using a hashtag here to signify that actAsUser is an instance method and not a static method)...
Read more >
Method has the same erasure as another method in type
This means that although your method signature is no longer formally equal to my superclass' signature, your method still overrides.
Read more >
Untitled
Find a one-night stand or a hookup you can also hang out with. Which dating site is best for serious relationships? What is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found