we are currently trying to build a custom shopify app that features user role based access. Is there any way to use the request from the app-admin or some other way to check which access level the currently logged in user has on the shopify admin?
Hey again @Tim_Dehler - right now, thereâs not too much staff member /user data available to query via the API, but we do surface some info that might be helpful:
You can use the StaffMember object to pull their account type (the most relevant enums would be to see if theyâre restricted members or if they can access the admin) and to see if theyâre the shop owner.
At one point, I believe we did offer more user data on the object, but that has been deprecated. Hope this helps - more than happy to set up a feature request on my end here if youâd like to share a use case, definitely understand how this would be useful!
Hello Sir, Iâm building a custom embedded app on Shopify POS, and I also want to get logged in Userâs data. Could you please tell me that will this API work for me, or is there anything else I can use?
Hey @Banibrata_Manna with Shopify POS, access to the user data is a bit more limited, but using the POS UI Extensionâs available APIs you could get some session information that could tell you about the user/device/session history:
The API with the most user-related info would be the Session API, which should let you get the user and staff member IDs for a specific POS tracking session. You could then cross reference that staff member Id to get more data using the StaffMember Admin API object Tim and I were talking about above.
Hope this helps - let me know if I can help out further!
Thanks, @Alan_G , Is there any way to use these but avoid registering extension because my app will not include toml files, I want locationId, that could help me.
Hey again @Banibrata_Manna - you should be able to get the location ID through the Session API as an extension app, without creating a âfullâ app, if that makes sense. It wouldnât allow you to cross reference the Admin API to get the plain language name of the location, but if you did just need the numerical ID of a location, that might work for your use case.
Hope this helps, again, let me know if I can clarify anything
Okay Thanks @Alan_G Sir, I only need the numerical ID, but we do need to create an extension, and my project plan doesnât include making any extension.
And could you please tell me if the user id(the one In JWT token we get from getSessionToken api of app-bridge) can be same for two users from two different shops. I think it is the unique identifier for an user in context of a each shop on Shopify.
For the JWT token user IDs, the user ID from getSessionToken is technically unique within each shopâs context, so youâre definitely on point there. While it uniquely identifies a user within a specific shop, the same numerical ID could potentially exist in different shops since theyâre shop-scoped rather than globally unique across all of Shopify. You should be able to use other fields like iss to determine which shop a session ID belongs too though:
For your question about accessing the location ID without extensions, unfortunately for POS embedded apps, extensions are really the only supported way to access device and session data like location IDs. The POS environment has tighter security restrictions, and extensions provide the necessary APIs to safely interact with POS data.
It does look like youâve looked into seeing if your app would work as an embedded admin app instead (through App Bridge) though? If you wanted to go with that route, that would give you access to App Bridge APIs which might better suit your needs. Also, just to mention - the TOML configuration approach is actually designed to simplify app development, so it might be worth reconsidering if it could work for your use case.
Hope this helps clarify things! Let me know if you have any other questions
Thanks @Alan_G Sir, I really appreciate your effort with my queries.
Can you please tell me, will the @shopify/app-bridge-react dependency work in Vue app to get shopify object.
Iâm trying to log shopify object but getting an error that says âshopify global not definedâ and I want to get location ID from it, I think this could work.
Hey @Banibrata_Manna - usually that âshopify global not definedâ error pops up when an app is being initiated outside of a Shopify App Bridge iframe. Thereâs a bit more info here that might help with troubleshooting the issue:
Let me know if I can clarify anything or help out further if youâre still encountering any blockers/issues, though!
Hey again @Banibrata_Manna, happy to help with this. I just want to clarify if youâre building a POS extension or an Admin-based app using app bridge? If youâre using app bridge, the App Bridge POS API (more info here), currently you can only retrieve location data, not modify it:
Youâd want to run something like this:
await shopify.pos.location();
We do reccommend using POS UI extensions though if you want more on-device control: POS UI extensions
Hope Iâm understanding things correctly, let me know if I can help out further!
Thanks @Alan_G Sir, The Embedded App Iâm building runs on Admin and Shopify POS both using app bridge, but it doesnât use any extensions because extensions are not the part of our plan.
also Iâm getting a compailation error that says the Cannot find name âshopifyâ.
And FYI, my app is built on Ionic + Vue, TypeScript
For your immediate TypeScript/Vue issue there, the shopify global usually isnât available until App Bridge is properly initialized. Usually, we canât assist with non-Shopify library related code assistance, but for Vue with TypeScript, youâd generally need to set up something like this:
import { createApp } from '@shopify/app-bridge';
const app = createApp({
apiKey: 'your-api-key',
host: 'your-host-parameter',
});
// For TypeScript, you may need to declare the global
declare global {
interface Window {
shopify: any;
}
}
Since youâre using TypeScript, Iâd recommend using this library here as it should help with getting App Bridge set up more smoothly:
Hope this helps, let me know if I can clarify anything more on my end here.
Thanks @Alan_G Sir, I also logged the isShopifyPos() in console, it says true and app bridge is created properly because Iâm sucessfully getting the session token from app bridge. The app is always accessed either from admin panel or a Shopify POS app.
I couldnât figure out what actually is going wrong.
Thanks, Iâll reach out again if I get stuck with any other question.
Hello @Alan_G Sir, Please tell me about Organizations on Shopify.
Can Multiple Shops(stores having different domains) exist under an organization?
Can a User in an Organization have same Shopifyâs internal user Id(which I get from App Bridgeâs Libraryâs Session Token) accross different Shops in an Organization?
Hey @Banibrata_Manna - good to hear from you again! It is possible for multiple shops with separate domains to exist under an organization that is tied to a single account. Thereâs a bit more info here:
When it comes to the user ID though, these would be on a shop by shop basis even if the user is present on multiple shops. Hope this helps as well, let me know if I can help out further as always.