private void ExchangeCodeForToken(string authorizationCode) { Task <LiveLoginResult> task = LiveAuthRequestUtility.ExchangeCodeForTokenAsync( this.clientId, null, LiveAuthUtility.BuildDesktopRedirectUrl(), authorizationCode); task.ContinueWith((Task <LiveLoginResult> t) => { this.OnExchangeCodeCompleted(t.Result); }); }
/// <summary> /// Generates a consent URL that includes a set of provided parameters. /// </summary> /// <param name="scopes">A list of scope values that the user will need to authorize.</param> /// <param name="options">A table of optional authorization parameters to be encoded into the URL.</param> /// <returns>The generated login URL value.</returns> public string GetLoginUrl(IEnumerable <string> scopes, IDictionary <string, string> options) { LiveUtility.ValidateNotEmptyStringEnumeratorArguement(scopes, "scopes"); string locale = null; string state = null; DisplayType display = DisplayType.WinDesktop; ThemeType theme = ThemeType.Win7; string redirectUrl = LiveAuthUtility.BuildDesktopRedirectUrl(); if (options != null) { if (options.ContainsKey(AuthConstants.Locale)) { locale = options[AuthConstants.Locale]; } if (options.ContainsKey(AuthConstants.ClientState)) { state = options[AuthConstants.ClientState]; } if (options.ContainsKey(AuthConstants.Display)) { string displayStr = options[AuthConstants.Display]; if (!Enum.TryParse <DisplayType>(displayStr, true, out display)) { throw new ArgumentException(ErrorText.ParameterInvalidDisplayValue, "display"); } } if (options.ContainsKey(AuthConstants.Theme)) { string themeStr = options[AuthConstants.Theme]; if (!Enum.TryParse <ThemeType>(themeStr, true, out theme)) { throw new ArgumentException(ErrorText.ParameterInvalidDisplayValue, "theme"); } } } if (locale == null) { locale = CultureInfo.CurrentUICulture.ToString(); } return(this.authClient.GetLoginUrl(scopes, redirectUrl, display, theme, locale, state)); }
private void RefreshToken(Action <LiveLoginResult> completionCallback) { if (this.refreshTokenInfo != null) { LiveAuthRequestUtility.RefreshTokenAsync( this.clientId, null, LiveAuthUtility.BuildDesktopRedirectUrl(), this.refreshTokenInfo.RefreshToken, null /*scopes*/ ).ContinueWith(t => { this.OnRefreshTokenCompleted(t.Result, completionCallback); }); } else { LiveLoginResult result = new LiveLoginResult(LiveConnectSessionStatus.Unknown, null); this.OnRefreshTokenCompleted(result, completionCallback); } }