cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get access token with C#

Get access token with C#

irenee83
Helpful | Level 5

I'm making xamarin forms app that must save sqlite database in user dropbox account. I have created the required app to connect my xamarin forms app to dropbox, but i am looking for the C# code to get the access token for login. I have tried these instructions (https://gist.github.com/thomashagstrom/b0856a383bcdcf905c7a774c8c1b0879) with no success. Can you help me with ? Thank.

5 Replies 5

Re: Get access token with C#

Greg-DB
Dropboxer

The .NET SDK isn't officially supported for Xamarin, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though. 

 

For reference though, if you need to implement the OAuth app authorization flow, you can find the documentation here. And here's where it's implemented in the .NET SDK for reference.

Re: Get access token with C#

irenee83
Helpful | Level 5

Ok, thank. I will quickly try it. I was trying some code, and I have been able to see the authorization code in the device browser, the code that must be used in the post request to get the access token. My problem in this way is that i don't know how to retrieve this code displayed in the url bar and put it in the post request. If there is a method that can extract this code from the redirectde url in C#, i will try it also. Thank for the replay.

Re: Get access token with C#

Greg-DB
Dropboxer

Yes, when using the OAuth 2 app authorization "code" flow with a redirect URI, the authorization code is returned in a URL parameter with the name "code" on the redirect URI. You would need to retrieve that parameter value, though exactly how you do so will depend on whatever web framework you're using. Or, if you're not using a redirect URI, you can have the user manually copy/paste the code into your app.

Re: Get access token with C#

irenee83
Helpful | Level 5

Thank Greg K for the interest. I'm trying Webview and the device native Browser (that I open with "await Browser.OpenAsync(authorizeUri, BrowserLaunchMode.SystemPreferred)" where "authorizeUri" is the authorization uri). But I alway failed. In the POST request, I must also put the redirect uri. Then, I would like to be sure about the "REDIRECT URI". I've read its definition a lot, but I am not very sure how to set its. The one that I'm using is valid ? I don't know. It is "https://dev-5-6ei48x.auth0.com/login/callback". What are the steps and rules to get this redirect url (not "WHERE" to put it but "HOW" to get it). 

Re: Get access token with C#

Greg-DB
Dropboxer

Please note that per the documentation, you should be processing the OAuth flow in the system browser, not in a web view.

 

Anyway, the "redirect URI" is where you want to send the end-user after they authorize your app. I can't tell you what it should be though since it will be specific to your app. You as the developer define this URI based on how you build your app. That is, you need to set the route on your app where you want to receive the user at that step in the OAuth flow to finish it. 

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    irenee83 Helpful | Level 5
What do Dropbox user levels mean?
Need more support?