All things Shopify and commerce
Hello all,
i am using Nextjs as a frontend and shopify as a backend i am using storefronts graphql api . I want to login with social media like gmail, facebook . how i can get storefront api for social login. give me any solution for it .
Thank you in advance
Hello @Harsh12341
NEXT_PUBLIC_SHOPIFY_API_KEY=<your_shopify_api_key> NEXT_PUBLIC_SHOPIFY_API_SECRET=<your_shopify_api_secret>
import Shopify from "shopify"; const client = new Shopify({ apiKey: process.env.NEXT_PUBLIC_SHOPIFY_API_KEY, apiSecret: process.env.NEXT_PUBLIC_SHOPIFY_API_SECRET, });
Use the client instance to make a request to the /admin/customers/socialLogin endpoint.
const response = await client.request({ method: "POST", path: "/admin/customers/socialLogin", body: { socialProvider: "facebook", accessToken: "your_facebook_access_token", }, });
You can use the customer's email address and Shopify customer ID to create a new user account in your Next.js application.
Here is an example of how to create a new user account:
const user = await client.customers.create({ email: response.customer.email, password: "your_password", });
const redirectUrl = `/`; await client.redirect(redirectUrl);
The user will be redirected to your application's home page and they will be logged in.
But then how do I validate the session from this point to check authentication status? If the user for example tries to access another protected page how do I validate the token in the next middleware to confirm that this user is still logged in with shopify?
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025