Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
NachoMurphy
9 years agoExplorer | Level 3
Dropbox Xamarin OAuth Flow Question - Retrieving the Access Token
Hi there, I have a mobile app on Android that uses Xamarin's tools to do some basic dropbox operations. In the past we used the Sync SDK to use dropbox quite easily. With the June v1 shut off comin...
NachoMurphy
9 years agoExplorer | Level 3
Thanks for the response.
In light of the Web View news, I'm going to opt for only using the .NET SDK after all. It's true that I had been using parts of both SDKs before. It's frustrating because in the time between my posts I had implemented a WebView soution that was partially working. Oh well, so much for that.
Back to the issue then: I'm using the .NET approach to the OAuth flow. I use the android browser to navigate to the authorize URL. Then the user would sign in if needed and hit Allow. My newest issue then becomes: I get how the .NET SDK example uses BrowserNavigating to capture the event and can then parse the access token from the URI, but how would I do that for android? Is there a way to attach a listener to the browser intent? This is the immediate obstacle I'm facing at present.
Here's some revised code:
private void HandleDropboxOperation()
{
waitingOnDropboxUpload = true;
taskCode = AuthActivity.RandomString(16);
Toast.MakeText(this, "Uploading...", ToastLength.Short).Show();
//see if there is an existing user access token stored
sp = GetSharedPreferences(SharedPrefsName, FileCreationMode.Private);
AccessTokenValue = sp.GetString(AccessTokenKey, string.Empty);
if (AccessTokenValue.Equals(string.Empty))
{
this.OAth2State = Guid.NewGuid().ToString("N");
var authorizeUri = DropboxOAuth2Helper.GetAuthorizeUri(OAuthResponseType.Token, DropboxAppKey, new Uri(RedirectUri), state: Guid.NewGuid().ToString("N"));
//no browser object available - use intent instead
Android.Net.Uri.Builder b = new Android.Net.Uri.Builder();
b.AppendPath(authorizeUri.ToString());
Intent browserIntent = new Intent(Intent.ActionView, b.Build());
StartActivityForResult(Intent.CreateChooser(browserIntent, "Open With"), 1);
//below is from the .NET SDK code - how to implement in Android?
//OAuth2Response result = DropboxOAuth2Helper.ParseTokenFragment(e.Uri);
//proceed with upload after token is obtained
}
else
{
InitiateUpload();
}
}NachoMurphy
9 years agoExplorer | Level 3
Similar question as well: For the Java SDK, does the auth flow in the android part of the project require the official Dropbox app? It still seems unclear to me if using the Java SDK relies on having the official Dropbox App installed or not. If not, it's possible to just use web browser auth then, correct?
About 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!