Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // 1. Get authorization code that Capture returned to us
            this.Code = Request.QueryString["code"];

            // Set up the configuration for our particular app
            _janrainConfig = new Config("https://janrainlab.dev.janraincapture.com", "22xcaaga55yyb8d4t4akdy4vwmnezn2t", "fgpbwwc4asc7jufbtvd6sx2xdze7t6a4");

            // 2. Exchange the auth code for an access token
            string result = AuthenticateUser();
            // Get the result into an object
            AuthResult authResult = JsonConvert.DeserializeObject<AuthResult>(result);
            // Add the access token to the config object (so it can be used for the /entity call
            _janrainConfig.AccessToken = authResult.access_token;

            // 3. Retrieve the profile data
            string profileData = GetProfile();
            // Get the entity result into an object
            EntityResult entityResult = JsonConvert.DeserializeObject<EntityResult>(profileData);
            // Create a user profile object from the data returned by Capture
            UserProfile user = entityResult.result;

            // 4. Authorize the user in ASP.NET
            //    Here, we are passing in the user's email as the username, but you can pass in whatever makes sense

            // Create FormsAuth ticket
            // FormsAuthenticationTicket ticket = new FormsAuthenticationTicket("CustomAuth", false, Int32.Parse(authResult.expires_in));
            //FormsAuthentication.
            FormsAuthentication.RedirectFromLoginPage(user.Email, false);
        }
Esempio n. 2
0
 public Entity(Config config)
 {
     _config = config;
     _restClient = new RestClient(string.Empty, HttpVerb.POST);
     _restClient.AddParameter("client_id", _config.ClientId);
     _restClient.AddParameter("client_secret", _config.ClientSecret);
     _restClient.AddParameter("type_name", _config.TypeName);
 }
Esempio n. 3
0
 public Authenticater(Config configuration)
 {
     if(configuration != null)
         _configuration = configuration;
     //_restClient = new RestClient(_configuration.Endpoint, HttpVerb.POST);
     _restClient = new RestClient(_configuration.Endpoint, OAUTH_TOKEN_COMMAND, HttpVerb.POST);
     _restClient.AddParameter("client_id", _configuration.ClientId);
     _restClient.AddParameter("client_secret", _configuration.ClientSecret);
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("JUMP cli");

            Config myApp = new Config("https://xxx.janraincapture.com", "REDACTED", "REDACTED");

            Entity e = new Entity(myApp);
            string result = e.Count();
            Console.WriteLine("Total count: " + result);

            // result = e.Get("7751a187-9b3a-470b-a404-76731cafa9ad", Entity.IdType.UUID);

            // Console.WriteLine("User record for uuid->{0}: {1}", "", result);

            Authenticater a = new Authenticater(myApp);
            string token = a.GetToken("abc123", "farmer");

            Console.ReadLine();
        }
Esempio n. 5
0
 public Settings(Config config)
 {
     if(config != null)
         _config = config;
 }