Forum Discussion

Dipak pote's avatar
Dipak pote
New member | Level 1
11 years ago

How to authenticate without browser/app in c# ?

How to authenticate without browser/app in c# ? 

I did all the operation on dropbox but at the start(only one time) it ask me for the username & password

But I don't want any popup for authentication.I need to do it through code.

Here is my sample code where popup out for username & password then I get the token:

private void GetAccessToken()
{
var login = new DropboxLogin(apiKey,appSecret);
login.Owner = this;
login.ShowDialog();

if (login.IsSuccessfully)
{
Properties.Settings.Default.AccessToken = login.AccessToken.Value;
Properties.Settings.Default.Save();
}
else
{
MessageBox.Show("Failed to get access token................");
}

}

Can you pleas help me?

Thanks in advance! 

 

4 Replies

Replies have been turned off for this discussion
  • Richard P.'s avatar
    Richard P.
    Icon for Super User alumni rankSuper User alumni
    11 years ago

    You cant do it through code, the entire point of it is so you do not handle user credentials in your code, you pass it off to the Dropbox OAuth system and get a token back in return.

  • Dipak pote's avatar
    Dipak pote
    New member | Level 1
    11 years ago

    Can you please give me an idea to it. or any link which will help me to do it ?

  • Richard P.'s avatar
    Richard P.
    Icon for Super User alumni rankSuper User alumni
    11 years ago

    No, because you cannot do it - you must show the dialog as the SDK says - the code you have in your original post is the correct way to do it.

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

    Richard's correct, Dropbox API apps should not handle the user's credentials, but should use the OAuth flow instead. Note that this only needs to be done once per user. Once your app has an access token for a user, it can store and re-use the access token for future API calls for that user without further manual user intervention. Access tokens don't expire by themselves (though they can be manually revoked).

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!