public static async Task <PickerResult> OpenFileAsync(string clientId, bool multiSelect, IWin32Window owner = null) { const string msaAuthUrl = "https://login.live.com/oauth20_authorize.srf"; const string msaDesktopUrl = "https://login.live.com/oauth20_desktop.srf"; string startUrl, completeUrl; var scopes = multiSelect ? "onedrive_onetime.access:readfile|multi" : "onedrive_onetime.access:readfile|single"; Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add(OAuthConstants.ClientIdKeyName, clientId); urlParam.Add(OAuthConstants.ScopeKeyName, scopes); urlParam.Add(OAuthConstants.RedirectUriKeyName, msaDesktopUrl); urlParam.Add(OAuthConstants.ResponseTypeKeyName, "token"); startUrl = BuildUriWithParameters(msaAuthUrl, urlParam); completeUrl = msaDesktopUrl; FormOneDrivePicker authForm = new FormOneDrivePicker(startUrl, completeUrl); DialogResult result = await authForm.ShowDialogAsync(owner); if (DialogResult.OK == result) { return(authForm.PickerResult); } return(null); }
public static async Task<PickerResult> OpenFileAsync(string clientId, bool multiSelect, IWin32Window owner = null) { const string msaAuthUrl = "https://login.live.com/oauth20_authorize.srf"; const string msaDesktopUrl = "https://login.live.com/oauth20_desktop.srf"; string startUrl, completeUrl; var scopes = multiSelect ? "onedrive_onetime.access:readfile|multi" : "onedrive_onetime.access:readfile|single"; Dictionary<string, string> urlParam = new Dictionary<string,string>(); urlParam.Add("client_id", clientId); urlParam.Add("scope", scopes); urlParam.Add("redirect_uri", msaDesktopUrl); urlParam.Add("response_type", "token"); startUrl = BuildUriWithParameters(msaAuthUrl, urlParam); completeUrl = msaDesktopUrl; FormOneDrivePicker authForm = new FormOneDrivePicker(startUrl, completeUrl); DialogResult result = await authForm.ShowDialogAsync(owner); if (DialogResult.OK == result) { return authForm.PickerResult; } return null; }