public static string[] GetAuthorisationWithNoRedirectURL(AuthorisationSettings authSettings) { string[] resulturi = new string[2]; try { var uri = DropboxOAuth2Helper.GetAuthorizeUri(OAuthResponseType.Code, authSettings.DropboxAppKey, string.Empty, authSettings.SecurityToken, true); resulturi[0] = uri != null?uri.ToString() : string.Empty; resulturi[1] = string.Empty; } catch (Exception ex) { resulturi[0] = string.Empty; resulturi[1] = string.Format("Could not retrieve dropbox url due to exception: {0}", ex.ToString()); } return(resulturi); }
public static async Task <string> GetUserAuthorisationCode(string userAccessCode, AuthorisationSettings authSettings) { var message = ""; try { OAuth2Response response = await DropboxOAuth2Helper.ProcessCodeFlowAsync(userAccessCode, authSettings.DropboxAppKey, authSettings.DropboxSecretKey, authSettings.DropboxRedirectURI.ToString()); if (response != null) { //if (response.State != null && response.State.Equals(authSettings.SecurityToken)) //{ return(response.AccessToken); //} } else { message = "Failed: Access code is not secure."; } } catch (ArgumentException ex) { message = "Failed: " + ex.Message; } return(message); }