コード例 #1
0
        // 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());
                }

            }

        }
        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);
                }

            }

        }