protected void Button1_Click(object sender, EventArgs e)
    {
        var authorizer = new ShopifyAPIAuthorizer(shopName, ConsumerKey, ConsumerSecret);

        // get the Authorization URL and redirect the user
        var authUrl = authorizer.GetAuthorizationURL(new string[] { ShopifyScope }, Request.Url.AbsoluteUri);
        Response.Redirect(authUrl);
    }
예제 #2
0
        protected void GetAuthorization_Click(Object sender, EventArgs e)
        {
            string shopName = this.ShopName.Text;// get the shop name from the user (i.e. a web form)

            // you will need to pass a URL that will handle the response from Shopify when it passes you the code parameter
            Uri returnURL = new Uri(Request.Url.ToString());
            var authorizer = new ShopifyAPIAuthorizer(shopName,
                ConfigurationManager.AppSettings["Shopify.ConsumerKey"], // In this case I keep my key and secret in my config file
                ConfigurationManager.AppSettings["Shopify.ConsumerSecret"]);

            // get the Authorization URL and redirect the user
            var authUrl = authorizer.GetAuthorizationURL(new string[] { ConfigurationManager.AppSettings["Shopify.Scope"] }, returnURL.ToString());
            Response.Redirect(authUrl);
        }
예제 #3
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                // strip the .myshopify.com in case they added it
                string shopName = model.ShopName.Replace(".myshopify.com", String.Empty);

                // prepare the URL that will be executed after authorization is requested
                Uri requestUrl = this.Url.RequestContext.HttpContext.Request.Url;
                Uri returnURL = new Uri(string.Format("{0}://{1}{2}",
                                                        requestUrl.Scheme,
                                                        requestUrl.Authority,
                                                        this.Url.Action("ShopifyAuthCallback", "Account")));

                var authorizer = new ShopifyAPIAuthorizer(shopName, ConfigurationManager.AppSettings["Shopify.ConsumerKey"], ConfigurationManager.AppSettings["Shopify.ConsumerSecret"]);
                var authUrl = authorizer.GetAuthorizationURL(new string[] { ConfigurationManager.AppSettings["Shopify.Scope"] }, returnURL.ToString());
                return Redirect(authUrl);
            }

            return View(model);
        }
예제 #4
0
 public string GetLoginUrl(string shopName)
 {
     var returnURL = new Uri(CALLBACK_URL);
     authorizer = new ShopifyAPIAuthorizer(shopName, API_KEY, API_SECRET);
     var authUrl = authorizer.GetAuthorizationURL(RIGHTS, returnURL.ToString());
     return authUrl;
 }
        //
        // GET: /Shopify/init
        public ActionResult Init()
        {
            string appGuid = Request.Params["AppGuid"];
            string shopName = Request.Params["ShopName"];
            string apiKey = Request.Params["ApiKey"];
            string sharedSecret = Request.Params["SharedSecret"];

            var root = Request.Url.GetLeftPart(UriPartial.Authority);
            // you will need to pass a URL that will handle the response from Shopify when it passes you the code parameter
            Uri returnURL = new Uri(string.Format("{0}/Shopify/finalize?appGuid={1}&shopName={2}&apiKey={3}&sharedSecret={4}",
                root,
                appGuid,
                shopName,
                apiKey,
                sharedSecret));

            var authorizer = new ShopifyAPIAuthorizer(shopName, apiKey, sharedSecret);

            // get the Authorization URL and redirect the user
            var authUrl = authorizer.GetAuthorizationURL(new string[] {
                "read_content",
                "write_content",
                "read_themes",
                "write_themes",
                "read_products",
                "write_products",
                "read_customers",
                "write_customers",
                "read_orders",
                "write_orders",
                "read_script_tags",
                "write_script_tags" },
                returnURL.ToString());
            return Redirect(authUrl);
        }
    public string GetAuthURL(string shopName, string currentUri)
    {
        var authorizer = new ShopifyAPIAuthorizer(shopName, ConsumerKey, ConsumerSecret);

        // get the Authorization URL and redirect the user
        var authUrl = authorizer.GetAuthorizationURL(new string[] { ShopifyScope }, currentUri);
        return authUrl;
    }