public static async Task <Microsoft.OneDrive.OneDriveClient> GetOneDriveClientAsync(string clientId, OneDriveScopes[] scopes, IRefreshTokenHandler refreshTokenHandler = null) { LiveAuthClient authClient = new LiveAuthClient(clientId, refreshTokenHandler); var authScopes = from s in scopes select OAuthScopeAttribute.OAuthScopeForEnumValue(s); LiveLoginResult loginResult = await authClient.IntializeAsync(authScopes); if (loginResult.Status == LiveConnectSessionStatus.Connected) { return(new OneDriveClient(new LiveConnectClient(loginResult.Session))); } string startUrl = authClient.GetLoginUrl(authScopes); string endUrl = OAuthDesktopEndPoint; FormMicrosoftAccountAuth authForm = new FormMicrosoftAccountAuth(startUrl, endUrl); DialogResult result = await authForm.ShowDialogAsync(); if (DialogResult.OK == result) { return(await OnAuthComplete(authClient, authForm.AuthResult)); } return(null); }
// // GET: /OneNote/ public async Task <ActionResult> CreateNewPage() { LiveLoginResult loginStatus = await _liveAuthClient.InitializeWebSessionAsync(this.HttpContext); this.Response.Redirect(_liveAuthClient.GetLoginUrl(scopes)); return(null); }
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_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 string AskForRegistrationUrl(UserProfileInfo user, string redirectUrl, out int tempCredentialId) { LiveAuthClient auth = new LiveAuthClient(clientId, clientSecret, redirectUrl); string url = auth.GetLoginUrl(scopes); tempCredentialId = -1; return(url); }
// GET: OneNote public async Task <ActionResult> Index(string id) { // save the selected project id this.HttpContext.Session["onenote-project"] = id; LiveLoginResult loginStatus = await liveAuthClient.InitializeWebSessionAsync(this.HttpContext); return(Redirect(liveAuthClient.GetLoginUrl(scopes))); }
internal static async Task <string> GetLoginUrl() { // Create authClient if (authClient == null) { await Initialize(); } // Get the login url with the right scopes return(authClient.GetLoginUrl(scopes)); }
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 void LiveAuthClient_GetLoginUrl_WithInvalidDisplay() { 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] = "xbox"; 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 Task <ActionResult> Index() { LiveLoginResult loginStatus = await this.authClient.InitializeWebSessionAsync(HttpContext); switch (loginStatus.Status) { case LiveConnectSessionStatus.Expired: case LiveConnectSessionStatus.Unknown: string reAuthUrl = authClient.GetLoginUrl(scopes); return(new RedirectResult(reAuthUrl)); } return(RedirectToAction("Index", "Home")); }
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); }
// 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(); }
protected void Page_Load(object sender, EventArgs e) { string login = Request["login"]; string logout = Request["logout"]; string returnUrl = Request["ReturnUrl"]; if (login != null) { string[] scopes = new string[] { "wl.signin", "wl.basic" }; string loginUrl = liveAuthClient.GetLoginUrl(scopes, "https://jitad2015.waw.pl/Konto/webauth"); Response.Redirect(loginUrl, true); } if (logout != null) { if (returnUrl != null) { returnUrl = "&ReturnUrl=" + returnUrl; } string logoutUrl = "https://jitad2015.waw.pl/Konto/webauth?l=1" + returnUrl; if (logout == "2") { goto noneMS; } logoutUrl = liveAuthClient.GetLogoutUrl("https://jitad2015.waw.pl/Konto/webauth?l=1" + returnUrl); liveAuthClient.ClearSession(new HttpContextWrapper(Context)); noneMS: Session.Abandon(); Response.Redirect(logoutUrl, true); } if (Request["l"] != null) { if (returnUrl != null) { Response.Redirect("~/" + returnUrl, true); } else { Response.Redirect("~/", true); } } RegisterAsyncTask(new PageAsyncTask(getAuthResult)); }
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_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_WithEmptyScopes() { LiveAuthClient authClient = new LiveAuthClient("000000004802B729", "password", null); string url = authClient.GetLoginUrl(new string[] { }, "https://www.foo.com", null); }
internal string GetAuthorizeUrl(string callerUrl, string redirectUrl, int memberId) { var scopes = new[] { "wl.signin", "wl.offline_access", "onedrive.appfolder" }; return(_liveAuthClient.GetLoginUrl(scopes, redirectUrl)); }