Forum Discussion

nevermindx's avatar
nevermindx
Explorer | Level 4
2 years ago

Property 'auth' does not exist on type 'Dropbox'

auth

export class DropboxService {
private dbx: Dropbox

constructor() {
this.dbx = new Dropbox({
fetch,
clientId: dropboxConfig.clientId,
clientSecret: dropboxConfig.clientSecret,
})
}

generateAuthUrl() {
const authUrl = this.dbx.auth.getAuthenticationUrl(
dropboxConfig.redirectUri,
undefined,
'code',
)
return authUrl
} shows error auth doest not exist on Dropbox

3 Replies

  • Здравко's avatar
    Здравко
    Legendary | Level 20
    2 years ago

    Ha..🤣 You just found an imperfection out. 🤫

    The 'auth' field is there, but for whatever reason is not declared in type script. 🤷 That's why your interpreter complains.

    You can workaround as re-declare Dropbox and include the "missing" field or construct DropboxAuth object on your own, save a reference, and pass it on construction of Dropbox object - this.auth = new DropboxAuth({fetch, ...}); this.dbx = new Dropbox({auth}) (so instead of this.dbx.auth... you may use just this.auth...).

    Hope this helps.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    2 years ago

    Thanks for the report! I'll ask the team to add this to the types.

  • nevermindx's avatar
    nevermindx
    Explorer | Level 4
    2 years ago

    got the solution actually i had to do 

    importDropboxAuth } from 'dropbox' instead of  import { Dropbox } from 'dropbox'
     
    then i was able to to do  dbxAuth.getAuthenticationUrl()
     

About Dropbox API Support & Feedback

Node avatar for 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!