Exemplo n.º 1
0
        /// <summary>
        /// Gets the URL used in the first step of the web flow. The Web application should redirect to this URL.
        /// </summary>
        /// <param name="request">Parameters to the Oauth web flow login url</param>
        /// <returns></returns>
        public Uri GetGitHubLoginUrl(OauthLoginRequest request)
        {
            Ensure.ArgumentNotNull(request, "request");

            return new Uri(hostAddress, ApiUrls.OauthAuthorize())
                .ApplyParameters(request.ToParametersDictionary());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the URL used in the first step of the web flow. The Web application should redirect to this URL.
        /// </summary>
        /// <param name="request">Parameters to the Oauth web flow login url</param>
        /// <returns></returns>
        public Uri GetGitHubLoginUrl(OauthLoginRequest request)
        {
            Ensure.ArgumentNotNull(request, "request");

            return(new Uri(hostAddress, ApiUrls.OauthAuthorize())
                   .ApplyParameters(request.ToParametersDictionary()));
        }
Exemplo n.º 3
0
        public override async Task Login()
        {
            var request = new OauthLoginRequest(ClientId);
            this.Scopes.ForEach(s => request.Scopes.Add(s));
            var oauthUrl = GitHubClient.Oauth.GetGitHubLoginUrl(request);

            WebAuthenticationBroker.AuthenticateAndContinue(oauthUrl, WebAuthenticationBroker.GetCurrentApplicationCallbackUri());
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var loginRequest = new OauthLoginRequest(config.ClientID);
            var loginUri = unauthenticatedClient.Oauth.GetGitHubLoginUrl(loginRequest);
            var nsUrlRequest = new NSUrlRequest(new NSUrl(loginUri.OriginalString));

            webView.LoadStarted += HandleLoadStarted;
            webView.LoadRequest(nsUrlRequest);
        }
Exemplo n.º 5
0
 public override async Task Login()
 {
     var request = new OauthLoginRequest(ClientId);
     this.Scopes.ForEach(s => request.Scopes.Add(s));
     var oauthUrl = this.GitHubClient.Oauth.GetGitHubLoginUrl(request);
     var authResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, oauthUrl, WebAuthenticationBroker.GetCurrentApplicationCallbackUri());
     
     var responseString = authResult.ResponseData;
     var regex = new Regex(@"(?<=\?code=).*");
     await SetTokenFromCode(regex.Match(responseString).Value);
 }
Exemplo n.º 6
0
        private string GetOauthLoginUrl()
        {
            string csrf = Membership.GeneratePassword(24, 1);
            Session["CSRF:State"] = csrf;

            // 1. Redirect users to request GitHub access
            var request = new OauthLoginRequest(clientId)
            {
                Scopes = {"user", "notifications"},
                State = csrf
            };
            var oauthLoginUrl = client.Oauth.GetGitHubLoginUrl(request);
            return oauthLoginUrl.ToString();
        }
        public void GetAccessToken()
        {
            string csrf = Membership.GeneratePassword(24, 1);
            //Session["CSRF:State"] = csrf;

            var request = new OauthLoginRequest(ClientId)
            {
                Scopes = { "user", "notifications" },
                State = csrf
            };

            // NOTE: user must be navigated to this URL
            var oauthLoginUrl = Client.Oauth.GetGitHubLoginUrl(request);
            //.
        }
Exemplo n.º 8
0
        public void ReturnsUrlWithAllParameters()
        {
            var request = new OauthLoginRequest("secret")
            {
                RedirectUri = new Uri("https://example.com/foo?foo=bar"),
                Scopes = { "foo", "bar" },
                State = "canARY"
            };
            var connection = Substitute.For<IConnection>();
            connection.BaseAddress.Returns(new Uri("https://api.github.com"));
            var client = new OauthClient(connection);

            var result = client.GetGitHubLoginUrl(request);

            Assert.Equal("/login/oauth/authorize", result.AbsolutePath);
            Assert.Equal("?client_id=secret&redirect_uri=https%3A%2F%2Fexample.com%2Ffoo%3Ffoo%3Dbar&scope=foo%2Cbar&state=canARY", result.Query);
        }
Exemplo n.º 9
0
        private Response RedirectToOAuth()
        {
            var csrf = Guid.NewGuid().ToString();
            Session["CSRF:State"] = csrf;
            Session["OrigUrl"] = this.Request.Path;

            var request = new OauthLoginRequest(clientId)
            {
                Scopes = { "repo:status" },
                State = csrf
            };
            var oauthLoginUrl = client.Oauth.GetGitHubLoginUrl(request);
            return Response.AsRedirect(oauthLoginUrl.ToString());
        }
        private string GetOauthLoginUrl()
        {
            string csrf = Membership.GeneratePassword(24, 1);
            Session["CSRF:State"] = csrf;

            var request = new OauthLoginRequest(clientId)
            {
                Scopes = { "user", "notifications", "admin:org", "repo", "delete_repo" },
                State = csrf
            };
            var oauthLoginUrl = client.Oauth.GetGitHubLoginUrl(request);
            return oauthLoginUrl.ToString();
        }