How do you get details about authenticated user in Shopify node app?

jkasperbl
Shopify Partner
2 0 4

Can anyone explain how to get the email address, first name, and last name of the authenticated admin user from a Shopify app created in Node using the v3 CLI?

 

I previously used session.onlineAccessInfo.associated_user.email , session.onlineAccessInfo.associated_user.first_name, and session.onlineAccessInfo.associated_user.last_name with the v2 CLI code, but after enabling online tokens in the v3 CLI code, id is the only property I'm seeing on associated_user.

 

I see there's the StaffMember GraphQL endpoint which I could query, but that doesn't seem like a viable option due to the following notice:

 
Requires read_users access scope. Also: The app must be a finance embedded app or installed on a Shopify Plus or Advanced store. Contact Shopify Support to enable this scope for your app.

I don't need this data for anyone other than the authenticated admin user. How else can I retrieve this information? Is there a way to get this data populated on session.onlineAccessInfo.associated_user again as it was in the past?

Replies 2 (2)

jkasperbl
Shopify Partner
2 0 4

It turns out this data was being passed, but the default session storage options discard everything but the user id. The solution is to use either the out-of-the-box MemorySessionStorage option or implement your own custom storage.

articdigital
Shopify Partner
1 0 2

It does look to be the case: https://github.com/Shopify/shopify-api-js/blob/d61f811146dd9bad39969e33e9d2690251ae8009/lib/session/...

 

Any particular reason for this? I am wanting to automatically register a user when they install the app and this is the only place that I can see that provides the name and email of the user installing the application.

 

Are there any other way to get the user details?