pub struct AuthQuery {
pub code: String,
pub shop: String,
pub timestamp: String,
pub state: String,
pub host: String,
pub hmac: String,
}Expand description
OAuth callback query parameters from Shopify.
This struct represents all the query parameters that Shopify sends to your
redirect URI after a user authorizes your app. Use this with
validate_auth_callback to
verify the callback and exchange the code for an access token.
§Fields
All fields are strings as received from the query string:
code: Authorization code to exchange for tokensshop: Shop domain (e.g., “example.myshopify.com”)timestamp: Unix timestamp of the authorizationstate: State parameter for CSRF verificationhost: Base64-encoded host for embedded appshmac: HMAC signature for request validation
§Serialization
AuthQuery derives Serialize and Deserialize to facilitate parsing
from query strings using web frameworks like Axum or Actix-web.
§Example
use shopify_sdk::auth::oauth::AuthQuery;
let query = AuthQuery::new(
"auth-code".to_string(),
"my-shop.myshopify.com".to_string(),
"1699999999".to_string(),
"csrf-state".to_string(),
"aG9zdC12YWx1ZQ==".to_string(),
"abc123def456".to_string(),
);
assert_eq!(query.code, "auth-code");
assert_eq!(query.shop, "my-shop.myshopify.com");Fields§
§code: StringThe authorization code from Shopify.
This code is exchanged for an access token via a POST request to
https://{shop}/admin/oauth/access_token.
shop: StringThe shop domain that authorized the app.
This is the full domain (e.g., “example.myshopify.com”).
timestamp: StringUnix timestamp of when the authorization was granted.
state: StringThe state parameter for CSRF protection.
This should match the state generated by begin_auth().
host: StringBase64-encoded host for embedded apps.
Used by Shopify’s App Bridge for embedded app authentication.
hmac: StringHMAC signature for verifying the request authenticity.
This is computed by Shopify using your API secret key.
Implementations§
Source§impl AuthQuery
impl AuthQuery
Sourcepub const fn new(
code: String,
shop: String,
timestamp: String,
state: String,
host: String,
hmac: String,
) -> Self
pub const fn new( code: String, shop: String, timestamp: String, state: String, host: String, hmac: String, ) -> Self
Creates a new AuthQuery with all fields.
§Arguments
code- Authorization code from Shopifyshop- Shop domaintimestamp- Unix timestamp stringstate- CSRF state parameterhost- Base64-encoded hosthmac- HMAC signature
§Example
use shopify_sdk::auth::oauth::AuthQuery;
let query = AuthQuery::new(
"code123".to_string(),
"shop.myshopify.com".to_string(),
"1700000000".to_string(),
"state456".to_string(),
"host789".to_string(),
"hmac012".to_string(),
);Sourcepub fn to_signable_string(&self) -> String
pub fn to_signable_string(&self) -> String
Converts the query parameters to a signable string for HMAC verification.
This produces a string suitable for HMAC computation by:
- Excluding the
hmacparameter - Sorting remaining parameters alphabetically by key
- URI-encoding each value
- Joining as
key=value&key=valueformat
§Returns
A string ready for HMAC-SHA256 computation.
§Example
use shopify_sdk::auth::oauth::AuthQuery;
let query = AuthQuery::new(
"code123".to_string(),
"shop.myshopify.com".to_string(),
"1700000000".to_string(),
"state456".to_string(),
"host789".to_string(),
"hmac-ignored".to_string(),
);
let signable = query.to_signable_string();
// Parameters are sorted alphabetically: code, host, shop, state, timestamp
assert!(signable.starts_with("code="));
assert!(signable.contains("&shop="));
assert!(!signable.contains("hmac")); // hmac is excludedTrait Implementations§
Source§impl<'de> Deserialize<'de> for AuthQuery
impl<'de> Deserialize<'de> for AuthQuery
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for AuthQuery
impl StructuralPartialEq for AuthQuery
Auto Trait Implementations§
impl Freeze for AuthQuery
impl RefUnwindSafe for AuthQuery
impl Send for AuthQuery
impl Sync for AuthQuery
impl Unpin for AuthQuery
impl UnwindSafe for AuthQuery
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.