public void ShouldCreateAuthorizationURL() { var sa = new Sharpify.ShopifyAPIAuthorizer("atkinson-cafe", "apikey", "sekritpassword"); Console.WriteLine(sa.GetAuthorizationURL(new string[] { "dsafsaf" }, "http://www.google.com")); Assert.AreEqual("https://atkinson-cafe.myshopify.com/admin/oauth/authorize?client_id=apikey&scope=dsafsaf&redirect_uri=http%3a%2f%2fwww.google.com", sa.GetAuthorizationURL(new string[] { "dsafsaf" }, "http://www.google.com")); }
public void BeforeFixture() { try { // because it's so expensive on requests, get our authorization key once for the entire integration test suite // this Task will become ready once Shopify redirects our browser back to us with the test shop's consent (in the form of the access token) var redirectReplyPromise = ListenForIncomingShopTokenFromRedirect(5409); Console.WriteLine("Attempting to authorize against store " + TestStoreName); var sa = new Sharpify.ShopifyAPIAuthorizer(TestStoreName, ConfigurationManager.AppSettings ["Shopify.TestAppKey"], ConfigurationManager.AppSettings ["Shopify.TestAppSecret"]); var authUrl = sa.GetAuthorizationURL(new string[] { "write_content", "write_themes", "write_products", "write_customers", "write_script_tags", "write_orders" }, ConfigurationManager.AppSettings ["Shopify.TestHttpServerUri"]); Console.WriteLine(authUrl); // pop a web browser with the authorization UI: Process.Start(authUrl); Console.WriteLine("Waiting for Shopify to answer..."); redirectReplyPromise.Wait(); var shopCode = redirectReplyPromise.Result; Assert.NotNull(shopCode); Console.WriteLine("Got code: " + shopCode); var authTask = sa.AuthorizeClient(shopCode); authTask.Wait(); // acquire our authorization token for actual API requests AuthorizationState = authTask.Result; ShopifyClient = new ShopifyAPIContext(AuthorizationState, new JsonDataTranslator()); } catch (Exception e) { using (var fd = new StreamWriter("sharpify_test_before_fixture_error.txt")) { fd.Write(e.ToString()); } throw new Exception("Rethrowing exception emitted during BeforeFixture()", e); } }
public void BeforeFixture() { try { // because it's so expensive on requests, get our authorization key once for the entire integration test suite // this Task will become ready once Shopify redirects our browser back to us with the test shop's consent (in the form of the access token) var redirectReplyPromise = ListenForIncomingShopTokenFromRedirect (5409); Console.WriteLine ("Attempting to authorize against store " + TestStoreName); var sa = new Sharpify.ShopifyAPIAuthorizer (TestStoreName, ConfigurationManager.AppSettings ["Shopify.TestAppKey"], ConfigurationManager.AppSettings ["Shopify.TestAppSecret"]); var authUrl = sa.GetAuthorizationURL (new string[] { "write_content", "write_themes", "write_products", "write_customers", "write_script_tags", "write_orders" }, ConfigurationManager.AppSettings ["Shopify.TestHttpServerUri"]); Console.WriteLine (authUrl); // pop a web browser with the authorization UI: Process.Start (authUrl); Console.WriteLine ("Waiting for Shopify to answer..."); redirectReplyPromise.Wait (); var shopCode = redirectReplyPromise.Result; Assert.NotNull (shopCode); Console.WriteLine ("Got code: " + shopCode); var authTask = sa.AuthorizeClient (shopCode); authTask.Wait (); // acquire our authorization token for actual API requests AuthorizationState = authTask.Result; ShopifyClient = new ShopifyAPIContext (AuthorizationState, new JsonDataTranslator ()); } catch (Exception e) { using (var fd = new StreamWriter("sharpify_test_before_fixture_error.txt")) { fd.Write (e.ToString ()); } throw new Exception ("Rethrowing exception emitted during BeforeFixture()", e); } }
public void ShouldCreateAuthorizationURL() { var sa = new Sharpify.ShopifyAPIAuthorizer("atkinson-cafe", "apikey", "sekritpassword"); Console.WriteLine (sa.GetAuthorizationURL(new string[] { "dsafsaf" }, "http://www.google.com")); Assert.AreEqual("https://atkinson-cafe.myshopify.com/admin/oauth/authorize?client_id=apikey&scope=dsafsaf&redirect_uri=http%3a%2f%2fwww.google.com", sa.GetAuthorizationURL(new string[] { "dsafsaf" }, "http://www.google.com")); }