// Util util = new Util(SecretConstants.BASE_URL);

        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!IsPostBack)
            {

                Util util = new Util(SecretConstants.BASE_URL);

                if (Session["token"] == null)
                {
                    string token = util.GetAccessToken(SecretConstants.CLIENT_ID,
                       SecretConstants.CLIENT_SECRET).access_token;
                    if (token == string.Empty)
                    {
                        //LogExtensions.Log("Authentication error");
                    }
                    Session["token"] = token;
                }

                bool bucketExist = util.IsBucketExist(SecretConstants.DEFAULT_BUCKET_KEY, Session["token"].ToString());
                if (!bucketExist)
                {
                    util.CreateBucket(SecretConstants.DEFAULT_BUCKET_KEY, Session["token"].ToString());
                }

            }

        }
        public void ProcessRequest(HttpContext context)
        {
            string respJson = string.Empty;

            Util util = new Util(SecretConstants.BASE_URL);

            AccessToken token = util.GetAccessToken(SecretConstants.CLIENT_ID,
                SecretConstants.CLIENT_SECRET);


            if (context.Session["token"] == null)
            {
                string accessToken = token.access_token;
                if (accessToken == string.Empty)
                {
                    //LogExtensions.Log("Authentication error");
                }
                context.Session["token"] = accessToken;
            }

            respJson = Newtonsoft.Json.JsonConvert.SerializeObject(token);
          
            context.Response.ContentType = "application/json";
            context.Response.Write(respJson);
        }
        public void ProcessRequest(HttpContext context)
        {
            string respJson = string.Empty;

            string BASE_URL = Credentials.BASE_URL;
            string CLIENT_ID = Credentials.CONSUMER_KEY;
            string CLIENT_SECRET = Credentials.CONSUMER_SECRET;


            Util util = new Util(BASE_URL);

            AccessToken token = util.GetAccessToken(CLIENT_ID, CLIENT_SECRET);
            string accessToken = token.access_token;


            respJson = Newtonsoft.Json.JsonConvert.SerializeObject(token);

            context.Response.ContentType = "application/json";
            context.Response.Write(respJson);
        }
        protected void Page_Load(object sender, EventArgs e)
        {


            if (!IsPostBack)
            {
                string BASE_URL = Credentials.BASE_URL;
                string CLIENT_ID = Credentials.CONSUMER_KEY;
                string CLIENT_SECRET = Credentials.CONSUMER_SECRET;
                string DEFAULT_BUCKET_KEY = Credentials.DEFAULT_BUCKET_KEY;

                Util util = new Util(BASE_URL);


                AccessToken token = util.GetAccessToken(CLIENT_ID,
                   CLIENT_SECRET);
                if (token == null)
                {
                    log.Error("Authentication error");

                    //Fatal error
                    Response.Redirect("Error.aspx");
                }
                else
                {
                    log.Info("Authentication success, token : " + token.access_token);
                }



                bool bucketExist = util.IsBucketExist(DEFAULT_BUCKET_KEY, token.access_token);
                if (!bucketExist)
                {
                    util.CreateBucket(DEFAULT_BUCKET_KEY, token.access_token);
                }

            }

        }