pub struct ShopifyApp {
pub access_mode: AccessMode,
pub auth_callback_url: String,
pub credentials: Credentials,
pub host: String,
pub scopes: Vec<&'static str>,
}
Fields§
§access_mode: AccessMode
§auth_callback_url: String
§credentials: Credentials
§host: String
§scopes: Vec<&'static str>
Implementations§
Source§impl ShopifyApp
This is an implementation of the ShopifyApp
struct.
impl ShopifyApp
This is an implementation of the ShopifyApp
struct.
§Examples
use shopify_app::ShopifyApp;
let app = ShopifyApp::new(); let nonce = app.new_nonce(); let auth_uri = app.new_auth_uri(“my-shop.myshopify.com”, “http://localhost:3000/auth”, &nonce); This method generates a new nonce value as a string.
A nonce (number used once) is a random value that is used to protect against replay attacks in authentication systems. This method uses the TextNonce
type from the ring
crate to generate a cryptographically secure random value and converts it into a string. The string is then modified by replacing plus signs with hyphens and forward slashes with underscores.
§Examples
use shopify_app::ShopifyApp;
let app = ShopifyApp::new(); let nonce = app.new_nonce(); This method generates a new authorization URI for the Shopify OAuth authentication flow.
The method takes a shop domain string &str
, a return URI string &str
, and a nonce string &str
as arguments and returns a String
. The shop
argument should be the domain of the Shopify shop that the application is being installed on, the return_uri
argument should be the URI that the user’s browser should be redirected to after authentication, and the nonce
argument should be a nonce value to protect against replay attacks.
The method uses the api_key
and scopes
fields of the credentials
field of the ShopifyApp
struct, and the access_mode
field of the struct, to construct the authorization URI using a format string. The URI is then returned.
§Examples
use shopify_app::ShopifyApp;
let app = ShopifyApp::new(); let nonce = app.new_nonce(); let auth_uri = app.new_auth_uri(“my-shop.myshopify.com”, “http://localhost:3000/auth”, &nonce);
Source§impl ShopifyApp
impl ShopifyApp
Sourcepub fn generate_hmac_bytes(
&self,
data: &[u8],
) -> GenericArray<u8, <Hmac<Sha256> as Mac>::OutputSize>
pub fn generate_hmac_bytes( &self, data: &[u8], ) -> GenericArray<u8, <Hmac<Sha256> as Mac>::OutputSize>
This method generates a HMAC (keyed-hash message authentication code) of the data passed as an argument as a byte array.
The method takes a slice of bytes &[u8]
as an argument and returns a type that implements the GenericArray
trait from the generic-array
crate, with the element type u8
and the size specified by the OutputSize
associated type of the HmacSha256
type from the hmac
crate.
The method uses the HmacSha256
type to create a new variable-length HMAC using the HmacSha256::new_varkey
method, passing in the secret
field of the credentials
field of the ShopifyApp
struct as a byte slice. The expect
method is called on the result to unwrap the Result
type that new_varkey
returns, which will panic if the key is invalid.
pub fn generate_hmac_hex(&self, data: &[u8]) -> String
pub fn generate_hmac_base64(&self, data: &[u8]) -> String
pub fn valid_hmac(&self, query_params: &Vec<(String, String)>) -> bool
Source§impl ShopifyApp
impl ShopifyApp
Sourcepub fn shopify_url(shop: &str) -> bool
pub fn shopify_url(shop: &str) -> bool
This method checks whether the given shop domain string is a valid Shopify shop domain.
The method takes a shop domain string &str
as an argument and returns a bool
.
Trait Implementations§
Source§impl Clone for ShopifyApp
impl Clone for ShopifyApp
Source§fn clone(&self) -> ShopifyApp
fn clone(&self) -> ShopifyApp
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more