C# Class ShopifySharp.ShopifyAuthorizationService

Datei anzeigen Open project: nozzlegear/ShopifySharp

Public Methods

Method Description
Authorize ( string code, string myShopifyUrl, string shopifyApiKey, string shopifySecretKey ) : Task

Authorizes an application installation, generating an access token for the given shop.

BuildAuthorizationUrl ( IEnumerable scopes, string myShopifyUrl, string shopifyApiKey, string redirectUrl = null, string state = null, IEnumerable grants = null ) : Uri

Builds an authorization URL for Shopify OAuth integration.

BuildAuthorizationUrl ( IEnumerable scopes, string myShopifyUrl, string shopifyApiKey, string redirectUrl = null, string state = null, IEnumerable grants = null ) : Uri

Builds an authorization URL for Shopify OAuth integration.

IsAuthenticProxyRequest ( NameValueCollection querystring, string shopifySecretKey ) : bool

Determines if an incoming proxy page request is authentic. Conceptually similar to IsAuthenticRequest(NameValueCollection, string), except that proxy requests use HMACSHA256 rather than MD5.

IsAuthenticRequest ( NameValueCollection querystring, string shopifySecretKey ) : bool

Determines if an incoming request is authentic.

IsAuthenticWebhook ( NameValueCollection requestHeaders, Stream inputStream, string shopifySecretKey ) : Task

Determines if an incoming webhook request is authentic.

IsAuthenticWebhook ( NameValueCollection requestHeaders, string requestBody, string shopifySecretKey ) : bool

Determines if an incoming webhook request is authentic.

IsValidMyShopifyUrl ( string url ) : Task

A convenience function that tries to ensure that a given URL is a valid Shopify store by checking the response headers for X-ShopId.

Method Details

Authorize() public static method

Authorizes an application installation, generating an access token for the given shop.
public static Authorize ( string code, string myShopifyUrl, string shopifyApiKey, string shopifySecretKey ) : Task
code string The authorization code generated by Shopify, which should be a parameter named 'code' on the request querystring.
myShopifyUrl string The store's *.myshopify.com URL, which should be a paramter named 'shop' on the request querystring.
shopifyApiKey string Your app's public API key.
shopifySecretKey string Your app's secret key.
return Task

BuildAuthorizationUrl() public static method

Builds an authorization URL for Shopify OAuth integration.
public static BuildAuthorizationUrl ( IEnumerable scopes, string myShopifyUrl, string shopifyApiKey, string redirectUrl = null, string state = null, IEnumerable grants = null ) : Uri
scopes IEnumerable An array of — the permissions that your app needs to run.
myShopifyUrl string The shop's *.myshopify.com URL.
shopifyApiKey string Your app's public API key.
redirectUrl string An optional URL to redirect the user to after integration. Overrides the Shopify app's default redirect URL.
state string An optional, random string value provided by your application which is unique for each authorization request. During the OAuth callback phase, your application should check that this value matches the one you provided to this method.
grants IEnumerable Requested grant types, which will change the type of access token granted upon OAuth completion. Only known grant type is "per-user", which will give an access token restricted to the permissions of the user accepting OAuth integration and will expire when that user logs out. Leave the grants array empty or null to receive a full access token that doesn't expire.
return System.Uri

BuildAuthorizationUrl() public static method

Builds an authorization URL for Shopify OAuth integration.
public static BuildAuthorizationUrl ( IEnumerable scopes, string myShopifyUrl, string shopifyApiKey, string redirectUrl = null, string state = null, IEnumerable grants = null ) : Uri
scopes IEnumerable An array of Shopify permission strings, e.g. 'read_orders' or 'write_script_tags'. These are the permissions that your app needs to run.
myShopifyUrl string The shop's *.myshopify.com URL.
shopifyApiKey string Your app's public API key.
redirectUrl string An optional URL to redirect the user to after integration. Overrides the Shopify app's default redirect URL.
state string An optional, random string value provided by your application which is unique for each authorization request. During the OAuth callback phase, your application should check that this value matches the one you provided to this method.
grants IEnumerable Requested grant types, which will change the type of access token granted upon OAuth completion. Only known grant type is "per-user", which will give an access token restricted to the permissions of the user accepting OAuth integration and will expire when that user logs out. Leave the grants array empty or null to receive a full access token that doesn't expire.
return System.Uri

IsAuthenticProxyRequest() public static method

Determines if an incoming proxy page request is authentic. Conceptually similar to IsAuthenticRequest(NameValueCollection, string), except that proxy requests use HMACSHA256 rather than MD5.
public static IsAuthenticProxyRequest ( NameValueCollection querystring, string shopifySecretKey ) : bool
querystring System.Collections.Specialized.NameValueCollection The collection of querystring parameters from the request. Hint: use Request.QueryString if you're calling this from an ASP.NET MVC controller.
shopifySecretKey string Your app's secret key.
return bool

IsAuthenticRequest() public static method

Determines if an incoming request is authentic.
public static IsAuthenticRequest ( NameValueCollection querystring, string shopifySecretKey ) : bool
querystring System.Collections.Specialized.NameValueCollection The collection of querystring parameters from the request. Hint: use Request.QueryString if you're calling this from an ASP.NET MVC controller.
shopifySecretKey string Your app's secret key.
return bool

IsAuthenticWebhook() public static method

Determines if an incoming webhook request is authentic.
public static IsAuthenticWebhook ( NameValueCollection requestHeaders, Stream inputStream, string shopifySecretKey ) : Task
requestHeaders System.Collections.Specialized.NameValueCollection The request's headers. Hint: use Request.Headers if you're calling this from an ASP.NET MVC controller.
inputStream Stream The request's input stream. This method does NOT dispose the stream. /// Hint: use Request.InputStream if you're calling this from an ASP.NET MVC controller.
shopifySecretKey string Your app's secret key.
return Task

IsAuthenticWebhook() public static method

Determines if an incoming webhook request is authentic.
public static IsAuthenticWebhook ( NameValueCollection requestHeaders, string requestBody, string shopifySecretKey ) : bool
requestHeaders System.Collections.Specialized.NameValueCollection The request's headers. Hint: use Request.Headers if you're calling this from an ASP.NET MVC controller.
requestBody string The body of the request.
shopifySecretKey string Your app's secret key.
return bool

IsValidMyShopifyUrl() public static method

A convenience function that tries to ensure that a given URL is a valid Shopify store by checking the response headers for X-ShopId.
public static IsValidMyShopifyUrl ( string url ) : Task
url string The URL of the shop to check.
return Task