Forum Discussion

ptallett's avatar
ptallett
Helpful | Level 6
8 years ago
Solved

How to use OAuth2 authentication APIs

I am writing a UWP app on Windows 10 with the .NET Dropbox API and want to allow users to login to their Dropbox. Note this is not a web app and I don't have a browser control.

 

var authUri = DropboxOAuth2Helper.GetAuthorizeUri(OAuthResponseType.Token, appKey, "http://localhost", appSecret, true, false);
var result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, authUri, redirect);


I always get a 400 Bad Request in the event log. What am I doing wrong? I've registered http://localhost on the portal.

Cheers,
Paul

  • I solved it! The redirect URL has to be registered with a trailing slash.

     

    Thanks for your help.

     

    I'm not clear how long my token will last and how I refresh it, could you explain.

     

    Love your API by the way, was a breeze to integrate into my app (except for this auth issue).

     

    Suggestions for improvement:

     

    - things like SearchMode.FilenameAndContent.Instance should be enums that are "or"able

    - Would like to search on content only, not name and content

    - I'd like a created date for the files and a size for folders

    - I'd like wildcards in the search - MyF??e.j*g

    - In fact the Google Drive API has a whole query language for search which is quite nice

    - Sharing.CreateSharedLinkWithSettingsAsync throwing an exception when the link already exists is dumb. Just return it to me, don't care if its already created

    - The Search API and List API should be merged into one API IMHO, but not a big deal

    - Thumbnails for PDF and PPT would be nice (like Google)

    - Content indexing of PDF and PPT would be nice (there are free IFilters for these)

    - Auth should save the token so I don't need to auth every time

     

    Cheers,

    Paul