/// <summary> /// Initializes a new instance of the RefreshTokenInfo class. /// </summary> /// <param name="refreshToken">The refresh token value.</param> /// <param name="userId">The user ID associated with the token.</param> public RefreshTokenInfo(string refreshToken, string userId) { LiveUtility.ValidateNotNullOrWhiteSpaceString(refreshToken, "refreshToken"); LiveUtility.ValidateNotNullOrWhiteSpaceString(userId, "userId"); this.RefreshToken = refreshToken; this.UserId = userId; }
/// <summary> /// Initializes an instance of LiveAuthClient class. /// </summary> /// <param name="clientId">The client Id of the app.</param> /// <param name="refreshTokenHandler">An IRefreshTokenHandler instance to handle refresh token persistency and retrieval.</param> public LiveAuthClient( string clientId, IRefreshTokenHandler refreshTokenHandler) { LiveUtility.ValidateNotNullOrWhiteSpaceString(clientId, "clientId"); this.authClient = new LiveAuthClientCore(clientId, refreshTokenHandler, this); this.syncContext = SynchronizationContextWrapper.Current; }
/// <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)); }
public void LiveUtility_ValidateUrl_InvalidScheme() { LiveUtility.ValidateUrl("ftp://foo.com/callback", "redirectUrl"); }
public void LiveUtility_ValidateUrl_WhiteSpace() { LiveUtility.ValidateUrl(" ", "redirectUrl"); }
public void LiveUtility_ValidateUrl_Null() { LiveUtility.ValidateUrl(null, "redirectUrl"); }
public void LiveUtility_ValidateUrl_https() { LiveUtility.ValidateUrl("https://www.foo.com", "redirectUrl"); }
public void LiveUtility_ValidateNotNullOrEmptyString_WhiteSpaceParameter() { LiveUtility.ValidateNotNullOrWhiteSpaceString(" \t ", "client_id"); }
public void LiveUtility_ValidateNotNullOrEmptyString_Normal() { LiveUtility.ValidateNotNullOrWhiteSpaceString("4303432830243", "client_id"); }
public void LiveUtility_ValidateNotNullParameter_Invalid() { LiveUtility.ValidateNotNullOrWhiteSpaceString(null, "client_id"); }
public void LiveUtility_ValidateNotNullParameter_Normal() { LiveUtility.ValidateNotNullParameter("4303432830243", "client_id"); }
/// <summary> /// Initializes the LiveAuthClient instance. /// This will trigger retrieving token with refresh token process if the app provides the refresh token via /// IRefreshTokenHandler.RetrieveRefreshTokenAsync method. /// </summary> /// <param name="scopes">The list of offers that the application is requesting user to consent for.</param> /// <returns>An async Task instance.</returns> public Task <LiveLoginResult> IntializeAsync(IEnumerable <string> scopes) { LiveUtility.ValidateNotNullParameter(scopes, "scopes"); return(this.authClient.InitializeAsync(scopes)); }
/// <summary> /// Exchange authentication code for access token. /// </summary> /// <param name="authenticationCode">The authentication code the app received from Microsoft authorization /// server during the user authorization process.</param> /// <returns></returns> public Task <LiveConnectSession> ExchangeAuthCodeAsync(string authenticationCode) { LiveUtility.ValidateNotNullOrWhiteSpaceString(authenticationCode, "authenticationCode"); return(this.authClient.ExchangeAuthCodeAsync(authenticationCode)); }
/// <summary> /// Initializes a new instance of the RefreshTokenInfo class. /// </summary> /// <param name="refreshToken">The refresh token value.</param> public RefreshTokenInfo(string refreshToken) { LiveUtility.ValidateNotNullOrWhiteSpaceString(refreshToken, "refreshToken"); this.RefreshToken = refreshToken; }