pub enum StorefrontToken {
Public(String),
Private(String),
}Expand description
A Shopify Storefront API access token.
This enum provides type-safe representation of storefront access tokens, automatically selecting the correct HTTP header based on the token type.
§Token Types
Public: For client-side applications with limited accessPrivate: For server-side applications with elevated access
§Security
The Debug implementation masks token values to prevent accidental exposure:
use shopify_sdk::StorefrontToken;
let token = StorefrontToken::Public("secret-token".to_string());
let debug = format!("{:?}", token);
assert_eq!(debug, "StorefrontToken::Public(*****)");§Example
use shopify_sdk::StorefrontToken;
let token = StorefrontToken::Public("my-token".to_string());
// Get the correct header name
assert_eq!(token.header_name(), "X-Shopify-Storefront-Access-Token");
// Get the token value
assert_eq!(token.header_value(), "my-token");Variants§
Public(String)
Public storefront access token for client-side applications.
Uses the X-Shopify-Storefront-Access-Token header.
These tokens have limited access and are safe to expose in client-side code.
Private(String)
Private storefront access token for server-side applications.
Uses the Shopify-Storefront-Private-Token header.
These tokens have elevated access and should only be used server-side.
Implementations§
Source§impl StorefrontToken
impl StorefrontToken
Sourcepub const fn header_name(&self) -> &'static str
pub const fn header_name(&self) -> &'static str
Returns the HTTP header name for this token type.
§Example
use shopify_sdk::StorefrontToken;
let public = StorefrontToken::Public("token".to_string());
assert_eq!(public.header_name(), "X-Shopify-Storefront-Access-Token");
let private = StorefrontToken::Private("token".to_string());
assert_eq!(private.header_name(), "Shopify-Storefront-Private-Token");Sourcepub fn header_value(&self) -> &str
pub fn header_value(&self) -> &str
Returns the token value as a string slice.
This is used to set the HTTP header value when making requests.
§Example
use shopify_sdk::StorefrontToken;
let token = StorefrontToken::Public("my-access-token".to_string());
assert_eq!(token.header_value(), "my-access-token");Trait Implementations§
Source§impl Clone for StorefrontToken
impl Clone for StorefrontToken
Source§fn clone(&self) -> StorefrontToken
fn clone(&self) -> StorefrontToken
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more