public void LiveAuthClient_GetLoginUrl_NoOptionalParameters() { LiveAuthClient authClient = new LiveAuthClient("000000004802B729", "password", null); Dictionary<string, string> options = new Dictionary<string, string>(); string url = authClient.GetLoginUrl(new string[] { "wl.signin", "wl.basic" }, "https://www.foo.com", null); Assert.AreEqual("https://login.live.com/oauth20_authorize.srf?client_id=000000004802B729&redirect_uri=https%3A%2F%2Fwww.foo.com&scope=wl.signin%20wl.basic&response_type=code&display=page&locale=en-US&state=", url); }
public void LiveAuthClient_GetLoginUrl_WithAllParams() { LiveAuthClient authClient = new LiveAuthClient("000000004802B729", "password", null); Dictionary<string, string> options = new Dictionary<string,string>(); options[AuthConstants.ClientState] = "unit tests"; options[AuthConstants.Locale] = "zh-hans"; options[AuthConstants.Display] = "touch"; options["random"] = "random"; string url = authClient.GetLoginUrl(new string[] { "wl.signin", "wl.basic" }, "https://www.foo.com", options); Assert.AreEqual("https://login.live.com/oauth20_authorize.srf?client_id=000000004802B729&redirect_uri=https%3A%2F%2Fwww.foo.com&scope=wl.signin%20wl.basic&response_type=code&display=touch&locale=zh-hans&state=appstate%3Dunit%2520tests", url); }
public async void TestLoginAsyncNullScopes() { var authClient = new LiveAuthClient("SomeClientId"); try { LiveLoginResult result = await authClient.LoginAsync(null); Assert.Fail("Expected ArgumentNullException to be thrown."); } catch (ArgumentNullException) { } }
public void TestInitializeAsyncNullScopes() { var authClient = new LiveAuthClient(); try { authClient.InitializeAsync(null); Assert.Fail("Expected ArgumentNullException to be thrown."); } catch (ArgumentNullException) { } }
/// <summary> /// Checks if the access token is still valid. If not, refreshes the token. /// </summary> protected bool RefreshTokenIfNeeded() { bool needsRefresh = false; LiveAuthClient authClient = this.LiveClient.Session.AuthClient; if (!this.refreshed && authClient != null) { this.refreshed = true; needsRefresh = authClient.RefreshToken(this.OnRefreshTokenOperationCompleted); } return(needsRefresh); }
public void Logout() { var liveAuthClient = new LiveAuthClient("000000004811DB42"); string logoutUrl = liveAuthClient.GetLogoutUrl(); var authForm = new LiveAuthWindow( logoutUrl, this.OnLiveAuthCompleted, "Logout" ); authForm.LogOut(logoutUrl); }
public async Task UnAuthenticateUserThroughLive() { try { LiveAuthClient LCAuth = new LiveAuthClient(); LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync(); // LCAuth.Logout(); LiveSession = null; } catch (LiveAuthException) { // Handle exceptions. } }
public void RegisterAccount(OAuthToken token, UserProfileInfo user) { LiveAuthClient auth = new LiveAuthClient(clientId, clientSecret, MogConstants.SKYDRIVE_REDIRECTURL); AuthCredential credential = new AuthCredential(); credential.CloudService = CloudStorageServices.Skydrive; credential.Token = token.AccessToken; credential.Refresh = token.RefreshToken; credential.Authentication = token.AuthenticationToken; credential.Status = CredentialStatus.Approved; credential.UserId = user.Id; credential.Login = auth.GetUserId(token.AuthenticationToken); this.repoAuthCredential.Create(credential); }
private void BeginLink(bool autoLogin) { // Returns if already linked. if (IsLinked) { Log("Already linked, ignored."); return; } // Stores auto-login setting. lock (_syncRoot) { _autoLoginOnInitFail = autoLogin; } // Makes sure the auth client exists. if (_authClient == null) { string clientId = null; try { clientId = (string)App.Current.Resources["LiveConnectClientID"]; } catch (Exception ex) { Log("Unable to fetch LiveConnectClientID from App resources."); throw new InvalidOperationException("Unable to fetch LiveConnectClientID from App resources.", ex); } _authClient = new LiveAuthClient(clientId); } // Starts initializing. try { Log("Starts InitializeAsync"); StartTaskAndContinueWith(() => _authClient.InitializeAsync(_Scopes), OnAuthClientInitializeCompleted); } catch (LiveAuthException ex) { // Ignores but dumps the exception. Log("LiveAuthException: " + ex.Message); Geowigo.Utils.DebugUtils.DumpException(ex, dumpOnBugSenseToo: false); // Raises an event. RaiseLinkAbort(ex); } }
public async Task <bool> Init(string clientId) { clientId.NotNull("clientId"); _authClient = new LiveAuthClient(clientId, this); var loginResult = await _authClient.InitializeAsync(_scopes); if (loginResult.Session != null) { _liveConnectClient = new LiveConnectClient(loginResult.Session); } SingInUrl = _authClient.GetLoginUrl(_scopes); return(true); }
public LiveConnectSession LoadSession(LiveAuthClient authClient) { var appData = IsolatedStorageSettings.ApplicationSettings; LiveConnectSession session = null; if (appData.Values.Count > 0) { session = new LiveConnectSession(authClient); if (appData.Contains(AuthConstants.RefreshToken)) { session.RefreshToken = appData[AuthConstants.RefreshToken] as string; } } return session; }
public LiveConnectSession LoadSession(LiveAuthClient authClient) { var appData = IsolatedStorageSettings.ApplicationSettings; LiveConnectSession session = null; if (appData.Values.Count > 0) { session = new LiveConnectSession(authClient); if (appData.Contains(AuthConstants.RefreshToken)) { session.RefreshToken = appData[AuthConstants.RefreshToken] as string; } } return(session); }
public void SaveSession(LiveConnectSession session) { if (session != null) { ApplicationDataContainer appData = ApplicationData.Current.RoamingSettings; if (appData.Values.ContainsKey(AuthConstants.AccessToken)) { appData.Values.Remove(AuthConstants.AccessToken); } appData.Values.Add(AuthConstants.AccessToken, session.AccessToken); if (appData.Values.ContainsKey(AuthConstants.AuthenticationToken)) { appData.Values.Remove(AuthConstants.AuthenticationToken); } appData.Values.Add(AuthConstants.AuthenticationToken, session.AuthenticationToken); if (!string.IsNullOrEmpty(session.RefreshToken)) { if (appData.Values.ContainsKey(AuthConstants.RefreshToken)) { appData.Values.Remove(AuthConstants.RefreshToken); } appData.Values.Add(AuthConstants.RefreshToken, session.RefreshToken); } if (appData.Values.ContainsKey(AuthConstants.Expires)) { appData.Values.Remove(AuthConstants.Expires); } appData.Values.Add(AuthConstants.Expires, session.Expires); if (appData.Values.ContainsKey(AuthConstants.Scope)) { appData.Values.Remove(AuthConstants.Scope); } appData.Values.Add(AuthConstants.Scope, LiveAuthClient.BuildScopeString(session.Scopes)); TestAuthClient.Scopes = session.Scopes; } }
async private Task <bool> userIsLoggedToOneDrive() { if (liveConnect == null) { return(false); } var auth = new LiveAuthClient(App.LSKEY_LIVE_CLIENT_ID); var result = await auth.InitializeAsync(new[] { "wl.signin", "wl.SkyDrive_update" }); if (result.Status == LiveConnectSessionStatus.NotConnected) { return(false); } return(true); }
private async Task <LiveConnectClient> GetLiveConnectClientAsync() { LiveAuthClient liveAuthClient = new LiveAuthClient(); string[] scopes = new[] { "wl.basic", "wl.signin", "wl.offline_access", "wl.skydrive", "wl.skydrive_update", "wl.contacts_skydrive" }; LiveLoginResult liveLoginResult = null; // Get Current live connection session // If session doesn't exist, get new one. liveLoginResult = await liveAuthClient.InitializeAsync(scopes); if (liveLoginResult.Status != LiveConnectSessionStatus.Connected) { liveLoginResult = await liveAuthClient.LoginAsync(scopes); } return(new LiveConnectClient(liveLoginResult.Session)); }
public static async Task <string> upload(string filename) { string res = ""; //diagLog("Uploading " + file); try { string[] requiredScope = { "wl.offline_access", "wl.skydrive_update" }; LiveAuthClient auth = new LiveAuthClient(Secrets.ClientID); await auth.InitializeAsync(requiredScope); if (auth.Session == null) { await auth.LoginAsync(requiredScope); } LiveConnectClient liveClient = new LiveConnectClient(auth.Session); string folderid = await GetSkyDriveFolderID(FOLDER, liveClient); if (folderid == null) { folderid = await createSkyDriveFolder(FOLDER, liveClient); res = "Created folder: " + FOLDER + "\n"; // , "ID:", folderid); } var store = IsolatedStorageFile.GetUserStoreForApplication(); if (store.FileExists(filename)) { var file = store.OpenFile(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read); LiveOperationResult operationResult = await liveClient.UploadAsync(folderid, filename, file, OverwriteOption.Overwrite); dynamic result = operationResult.Result; res += "Uploaded :" + result.name; //, "ID:", result.id); } else { throw new Exception("file does not exist"); } } catch (Exception exception) { res = "Error uploading file: " + exception.Message; } return(res); }
// TODO: REMOVE Login() / Logout() / OnLiveAuthCompleted() / etc. from this library, as they should not take a dependency // specifically on the Desktop Live ID library public void Login() { var liveAuthClient = new LiveAuthClient("000000004811DB42"); string startUrl = liveAuthClient.GetLoginUrl(new List <string>() { "service::prodkds.dns-cargo.com::MBI_SSL" }); var authForm = new LiveAuthWindow( startUrl, this.OnLiveAuthCompleted, "Login to the Microsoft Account associated with your Band" ); authForm.Login(); }
private async static Task <int> LogClient() { // create OneDrive auth client var authClient = new LiveAuthClient("000000004814E746"); // ask for both read and write access to the OneDrive LiveLoginResult result = await authClient.LoginAsync(new string[] { "wl.skydrive", "wl.skydrive_update" }); // if login successful if (result.Status == LiveConnectSessionStatus.Connected) { // create a OneDrive client LiveClient = new LiveConnectClient(result.Session); return(1); } return(0); }
private static ZumoTest CreateLiveSDKLoginTest() { return(new ZumoTest("Login via token with Live SDK", async delegate(ZumoTest test) { var client = ZumoTestGlobals.Instance.Client; #if !WINDOWS_PHONE var uri = client.ApplicationUri.ToString(); var liveIdClient = new LiveAuthClient(uri); #else string clientId; testPropertyBag.TryGetValue(ClientIdKeyName, out clientId); if (clientId == null) { test.AddLog("ClientId of Microsoft application not entered correctly."); return false; } var liveIdClient = new LiveAuthClient(clientId); #endif var liveLoginResult = await liveIdClient.LoginAsync(new string[] { "wl.basic" }); if (liveLoginResult.Status == LiveConnectSessionStatus.Connected) { var liveConnectClient = new LiveConnectClient(liveLoginResult.Session); var me = await liveConnectClient.GetAsync("me"); test.AddLog("Logged in as {0}", me.RawResult); if (liveLoginResult.Session.AuthenticationToken == null) { test.AddLog("Error, authentication token in the live login result is null"); return false; } else { var token = new JObject(new JProperty("authenticationToken", liveLoginResult.Session.AuthenticationToken)); var user = await client.LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount, token); test.AddLog("Logged in as {0}", user.UserId); return true; } } else { test.AddLog("Login failed."); return false; } }, ZumoTestGlobals.RuntimeFeatureNames.LIVE_LOGIN)); }
private LiveLoginResult GenerateLoginResultFrom(Stream responseStream) { IDictionary <string, object> jsonObj; try { using (var reader = new StreamReader(responseStream)) { var jsReader = new JsonReader(reader.ReadToEnd()); jsonObj = jsReader.ReadValue() as IDictionary <string, object>; } } catch (FormatException fe) { return(new LiveLoginResult( new LiveAuthException(AuthErrorCodes.ServerError, fe.Message))); } if (jsonObj == null) { return(new LiveLoginResult( new LiveAuthException(AuthErrorCodes.ServerError, ResourceHelper.GetString("ServerError")))); } if (jsonObj.ContainsKey(AuthConstants.Error)) { var errorCode = jsonObj[AuthConstants.Error] as string; if (errorCode.Equals(AuthErrorCodes.InvalidGrant, StringComparison.Ordinal)) { return(new LiveLoginResult(LiveConnectSessionStatus.NotConnected, null)); } string errorDescription = string.Empty; if (jsonObj.ContainsKey(AuthConstants.ErrorDescription)) { errorDescription = jsonObj[AuthConstants.ErrorDescription] as string; } return(new LiveLoginResult(new LiveAuthException(errorCode, errorDescription))); } LiveConnectSession newSession = LiveAuthClient.CreateSession(this.AuthClient, jsonObj); return(new LiveLoginResult(LiveConnectSessionStatus.Connected, newSession)); }
public async Task <LiveConnectClient> Login() { AuthClient = new LiveAuthClient("000000004015B444"); LiveLoginResult result = await AuthClient.InitializeAsync(new string[] { "wl.signin", "wl.skydrive" }); if (result.Status == LiveConnectSessionStatus.Connected) { return(new LiveConnectClient(result.Session)); } result = await AuthClient.LoginAsync(new string[] { "wl.signin", "wl.skydrive" }); if (result.Status == LiveConnectSessionStatus.Connected) { return(new LiveConnectClient(result.Session)); } return(null); }
public async Task <LiveConnectClient> Login() { _authClient = new LiveAuthClient("**your client id here**"); LiveLoginResult result = await _authClient.InitializeAsync(Scopes); if (result.Status == LiveConnectSessionStatus.Connected) { return(new LiveConnectClient(result.Session)); } result = await _authClient.LoginAsync(Scopes); if (result.Status == LiveConnectSessionStatus.Connected) { return(new LiveConnectClient(result.Session)); } return(null); }
public async Task <UserInfo> Authenticate() { var authClient = new LiveAuthClient(); var authResult = await authClient.LoginAsync(new List <string>() { "wl.signin", "wl.basic", "wl.skydrive" }); if (authResult.Status == LiveConnectSessionStatus.Connected) { var session = authResult.Session; var client = new LiveConnectClient(session); var liveOpResult = await client.GetAsync("me"); dynamic dynResult = liveOpResult.Result; return(new UserInfo { Id = dynResult.id, UserName = dynResult.name, Name = dynResult.name }); } return(null); }
private async void btnDisplayProfile_Click(object sender, RoutedEventArgs e) { try { LiveAuthClient auth = new LiveAuthClient(); LiveConnectClient liveClient = new LiveConnectClient(auth.Session); LiveOperationResult operationResult = await liveClient.GetAsync("me/picture"); dynamic result = operationResult.Result; BitmapImage image = new BitmapImage(new Uri(result.location, UriKind.Absolute)); this.imgResult.Source = image; } catch (LiveConnectException exception) { this.infoTextBlock.Text = "Error getting user picture: " + exception.Message; } }
public override async Task LoginAsync(IList <string> scopes) { if (string.IsNullOrEmpty(ClientId)) { EtcUtility.Instance.MsgBox("ClientId Required"); return; } if (AuthClient == null) { AuthClient = authClient = new LiveAuthClient(ClientId); } else { authClient = (LiveAuthClient)AuthClient; } try { IsBusy = true; await TaskEx.Run(() => { StaticFunctions.InvokeIfRequiredAsync(StaticFunctions.BaseContext, para => { //authClient.LoginCompleted += // (s, e) => // { // if (e.Status == LiveConnectSessionStatus.Connected) // { // LoadUser(); // } // }; //두번째 접속 시도 authClient.LoginAsync(scopes); }, null); }); } catch (Exception ex) { EtcUtility.Instance.MsgBox("NotConnectLiveID " + ex.Message); } }
public async Task <bool> SignInSkydrive() { try { _authClient = new LiveAuthClient(); LiveLoginResult loginResult = await this._authClient.LoginAsync(scopes); if (loginResult.Status == LiveConnectSessionStatus.Connected) { _liveClient = new LiveConnectClient(loginResult.Session); _session = loginResult.Session; return(true); } } catch (LiveAuthException authExp) { } return(false); }
public async Task <ConnectionResult> UpdateConnectionAsync() { var authClient = new LiveAuthClient(); var sessionStatus = LiveConnectSessionStatus.Unknown; LiveConnectSession session = null; try { // IMPORTANT! The app MUST be associated with the store, or a (otherwise unhelpful) NullReferenceException // will be raised when calling the AuthClient methods. var loginResult = await authClient.InitializeAsync(_scopes); sessionStatus = loginResult.Status; session = loginResult.Session; } catch (NullReferenceException) { // This is basically for the sake of example only, since an actual app obtained through the store will not have // the problem of not having been associated with the Windows Store. AppNotAssociatedWithStoreError(this, EventArgs.Empty); return(new ConnectionResult { SessionStatus = LiveConnectSessionStatus.NotConnected, CanLogout = false }); } catch (LiveAuthException ex) { // TODO - handle notification/display of error information //throw new InvalidOperationException("An error occurred during initialization.", ex); } // Set the current instance session based on the login var currentSession = sessionStatus == LiveConnectSessionStatus.Connected ? session : null; UpdateSession(currentSession); var result = new ConnectionResult { SessionStatus = sessionStatus, CanLogout = authClient.CanLogout, }; return(result); }
public override bool Logout() { LiveAuthClient authClient; if (AuthClient == null) { AuthClient = authClient = new LiveAuthClient(); } else { authClient = (LiveAuthClient)AuthClient; } authClient.Logout(); IsSignIn = false; User = null; return(true); }
private async void SignIn(object sender, RoutedEventArgs e) { try { LiveAuthClient auth = new LiveAuthClient(); LiveLoginResult loginResult = await auth.LoginAsync(new string[] { "wl.basic" }); if (loginResult.Status == LiveConnectSessionStatus.Connected) { this.infoTextBlock.Text = "Signed in."; } } catch (LiveAuthException exception) { this.infoTextBlock.Text = "Error signing in: " + exception.Message; } }
/// <summary> /// Upload a file to OneDrive /// </summary> /// <param name="Filename"></param> /// <param name="Content"></param> /// <returns></returns> public static async Task <int> UploadFileAsync(String Foldername, String Filename) { try { // create OneDrive auth client var authClient = new LiveAuthClient(); // ask for both read and write access to the OneDrive LiveLoginResult result = await authClient.LoginAsync(new string[] { "wl.signin", "wl.skydrive", "wl.skydrive_update" }); // if login successful if (result.Status == LiveConnectSessionStatus.Connected) { // create a OneDrive client liveClient = new LiveConnectClient(result.Session); // create a local file StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync(Filename); // create a folder string folderID = await GetFolderIDAsync(Foldername, true); if (string.IsNullOrEmpty(folderID)) { // return error return(0); } // upload local file to OneDrive await liveClient.BackgroundUploadAsync(folderID, file.Name, file, OverwriteOption.Overwrite); return(1); } } catch (Exception e) { return(e.Message.Length); } // return error return(0); }
/// <summary> /// Calls LiveAuthClient.Initialize to get the user login status. /// Retrieves user profile information if user is already signed in. /// </summary> private async void InitializePage() { try { this.authClient = new LiveAuthClient("0000000048087CFD"); LiveLoginResult loginResult = await this.authClient.InitializeAsync(scopes); if (loginResult.Status == LiveConnectSessionStatus.Connected) { this.btnLogin.Content = "Sign Out"; this.liveClient = new LiveConnectClient(loginResult.Session); this.GetMe(); } } catch (LiveAuthException authExp) { this.tbResponse.Text = authExp.ToString(); } }
public void TestExecute() { WebRequestFactory.Current = new TestWebRequestFactory(); #if NETFX_CORE LiveAuthClient authClient = new LiveAuthClient(); #elif WINDOWS_PHONE LiveAuthClient authClient = new LiveAuthClient("clientId"); #else #error This platform needs to be handled. #endif string clientId = "clientId"; string refreshToken = "refreshToken"; IEnumerable<string> scopes = new string[]{ "wl.basic" }; SynchronizationContextWrapper syncContext = SynchronizationContextWrapper.Current; var refreshOperation = new RefreshTokenOperation(authClient, clientId, refreshToken, scopes, syncContext); }
public async static Task <bool> SilentLoginAsync() { try { _auth = new LiveAuthClient(ClientId); LiveLoginResult result = await _auth.InitializeAsync(Scopes); if (result.Status == LiveConnectSessionStatus.Connected) { _client = new LiveConnectClient(result.Session); CurrentUserName = await GetUserNameAsync(); return(true); } } catch (Exception) { } _client = null; _auth = null; return(false); }
public void TestExecute() { WebRequestFactory.Current = new TestWebRequestFactory(); #if NETFX_CORE LiveAuthClient authClient = new LiveAuthClient(); #elif WINDOWS_PHONE LiveAuthClient authClient = new LiveAuthClient("clientId"); #else #error This platform needs to be handled. #endif string clientId = "clientId"; string refreshToken = "refreshToken"; IEnumerable <string> scopes = new string[] { "wl.basic" }; SynchronizationContextWrapper syncContext = SynchronizationContextWrapper.Current; var refreshOperation = new RefreshTokenOperation(authClient, clientId, refreshToken, scopes, syncContext); }
private async Task Authenticate() { try { var liveIdClient = new LiveAuthClient("000000004810306D"); var initResult = await liveIdClient.InitializeAsync(scopes); _session = initResult.Session; if (null == _session) { LiveLoginResult result = await liveIdClient.LoginAsync(scopes); if (result.Status == LiveConnectSessionStatus.Connected) { _session = result.Session; if (AuthenticationSuccessful != null) { AuthenticationSuccessful(); } } else { _session = null; if (AuthenticationFailed != null) { AuthenticationFailed(); } //MessageBox.Show("Unable to authenticate with Windows Live.", "Login failed :(", MessageBoxButton.OK); } } if (AuthenticationSuccessful != null) { AuthenticationSuccessful(); } } catch (Exception) { } }
/// <summary> /// Create a new RefreshTokenOperation object. /// </summary> /// <remarks>This constructor is used when exchanging the refresh token for the access token.</remarks> public RefreshTokenOperation( LiveAuthClient authClient, string clientId, string refreshToken, IEnumerable<string> scopes, SynchronizationContextWrapper syncContext) : base(new Uri(authClient.ConsentEndpoint + LiveAuthClient.TokenEndpoint), null, syncContext) { Debug.Assert(authClient != null, "authClient must not be null."); Debug.Assert(!string.IsNullOrEmpty(clientId)); Debug.Assert(!string.IsNullOrEmpty(refreshToken)); this.AuthClient = authClient; this.Body = String.Format( RefreshTokenOperation.RefreshTokenPostBodyTemplate, HttpUtility.UrlEncode(clientId), refreshToken, HttpUtility.UrlEncode(LiveAuthClient.BuildScopeString(scopes))); }
/// <summary> /// Create a new RefreshTokenOperation object. /// </summary> /// <remarks>This constructor is used when exchanging the verification code for the access token.</remarks> public RefreshTokenOperation( LiveAuthClient authClient, string clientId, string verificationCode, string redirectUri, SynchronizationContextWrapper syncContext) : base(new Uri(authClient.ConsentEndpoint + LiveAuthClient.TokenEndpoint), null, syncContext) { Debug.Assert(authClient != null, "authClient must not be null."); Debug.Assert(!string.IsNullOrEmpty(clientId)); Debug.Assert(!string.IsNullOrEmpty(verificationCode)); this.AuthClient = authClient; this.Body = String.Format( RefreshTokenOperation.AuthCodePostBodyTemplate, HttpUtility.UrlEncode(clientId), HttpUtility.UrlEncode(verificationCode), HttpUtility.UrlEncode(redirectUri)); }
public LiveConnectSession LoadSession(LiveAuthClient authClient) { ApplicationDataContainer appData = ApplicationData.Current.RoamingSettings; LiveConnectSession session = null; if (appData.Values.Count > 0) { session = new LiveConnectSession(authClient); if (appData.Values.ContainsKey(AuthConstants.AccessToken)) { session.AccessToken = appData.Values[AuthConstants.AccessToken] as string; } if (appData.Values.ContainsKey(AuthConstants.AuthenticationToken)) { session.AuthenticationToken = appData.Values[AuthConstants.AuthenticationToken] as string; } if (appData.Values.ContainsKey(AuthConstants.RefreshToken)) { session.RefreshToken = appData.Values[AuthConstants.RefreshToken] as string; } if (appData.Values.ContainsKey(AuthConstants.Expires)) { session.Expires = (DateTimeOffset)appData.Values[AuthConstants.Expires]; } if (appData.Values.ContainsKey(AuthConstants.Scope)) { session.Scopes = LiveAuthClient.ParseScopeString(appData.Values[AuthConstants.Scope] as string); TestAuthClient.Scopes = session.Scopes; } } return session; }
public TestAuthClient(LiveAuthClient liveAuthClient) { this.liveAuthClient = liveAuthClient; }
public void TestCanLogout() { var authClient = new LiveAuthClient(string.Empty); Assert.IsFalse(authClient.CanLogout); }
public void LiveAuthClient_GetUserId_Empty() { LiveAuthClient authClient = new LiveAuthClient("000000004802B729", "password", null); string uid = authClient.GetUserId(""); }
public void LiveAuthClient_GetUserId_Invalid() { LiveAuthClient authClient = new LiveAuthClient("000000004802B729", "password", null); string uid = authClient.GetUserId("etaeetwetw"); }
public void LiveAuthClient_GetLogoutUrl_Normal() { LiveAuthClient authClient = new LiveAuthClient("000000004802B729", "password", null); string url = authClient.GetLogoutUrl("http://www.foo.com/callback"); Assert.AreEqual("https://login.live.com/oauth20_logout.srf?client_id=000000004802B729&redirect_uri=http%3A%2F%2Fwww.foo.com%2Fcallback", url); }
public void LiveAuthClient_GetLoginUrl_InvalidSchemeRedirectUrl() { LiveAuthClient authClient = new LiveAuthClient("000000004802B729", "password", null); string url = authClient.GetLoginUrl(new string[] { "wl.signin" }, "ftp://www.foo.com/callback", null); }
public void LiveAuthClient_GetLoginUrl_WhiteSpaceRedirectUrl() { LiveAuthClient authClient = new LiveAuthClient("000000004802B729", "password", null); string url = authClient.GetLoginUrl(new string[] { "wl.signin" }, " ", null); }
public void LiveAuthClient_GetLoginUrl_WithEmptyScopes() { LiveAuthClient authClient = new LiveAuthClient("000000004802B729", "password", null); string url = authClient.GetLoginUrl(new string[] { }, "https://www.foo.com", null); }
public LiveConnectSession LoadSession(LiveAuthClient authClient) { return null; }