Shopify / shopify-app-js

MIT License
259 stars 101 forks source link

Using online access tokens doesn't return the associated user's email (anything other than id) #1249

Closed roxannems closed 1 month ago

roxannems commented 1 month ago

Issue summary

Before opening this issue, I have:

I am trying to build a shopify remix app. In the appConfig object in shopify.server.ts I have specified useOnlineTokens: true. Then in the loader function in the app.tsx file I am authenticating as admin and getting the session object. The session object contains the onlineAccessInfo field which in turn contains the associated_user field which then has id, first_name, last_name, email, locale. The issue is that only the id is coming through, the rest of the fields are undefined.

Expected behavior

I should see the actual values for the email, first_name, last_name, locale.

Actual behavior

Those fields show undefined for values.

Steps to reproduce the problem

  1. create a shopify remix app from the template
  2. go to app -> shopify.server.ts -> add useOnlineToken: true inside the config object given as aparm to the shopifyApp function
  3. go to app.tsx -> create a loader function like so:
export const loader = async ({ request }: LoaderFunctionArgs) => {
  const { session } = await authenticate.admin(request);
  console.log('@ This is the session object: ', session);
}
  1. install the app and run it
  2. notice in the server logs that the session object looks like this:
id: 'some-id',
shop: 'some-shop',
...
onlineAccessInfo: {
  associated_user: {
    id: 'some-user-id',
    first_name: undefined,
    last_name: undefined,
    email: undefined,
    locale: undefined
  }
}

Has anyone run into this? How did you manage to get the user's email? Are there any other steps I omitted? Thank you in advance.

lizkenyon commented 1 month ago

Hi there 👋

I tried your steps for reproduction on my store with a fresh remix app created with the CLI, and the online access info for my session is filled out correctly. I am able to see the first name, last name locale ect. 🤔

I am wondering if this could be related to how you are logged into your store? How are you installing your app, through the link with the CLI? When you look at the user you are installing your app with settings are the name and email filled out on their account page?

roxannems commented 1 month ago

Hey again,

Recently I also created a fresh remix app with the CLI and this time I received all the data I was expecting to receive, so I thought why not try to see what is different in the first project. I noticed the version of "@shopify/shopify-app-session-storage-prisma" is ^3.0.0 and that of "@shopify/shopify-app-remix" is ^2.1.0 (in the old project). However, in the newly created app they are ^5.0.2 and ^3.0.2 respectively.

Since it looks like you are releasing major versions quite often, it would be a great idea and very useful to include in the docs the dependency version that introduces a new feature/functionality.

roxannems commented 1 month ago

A dependency version update was necessary, check the comments above to see exactly which ones.

dkalariya commented 1 month ago

export const loader = async ({ request }: LoaderFunctionArgs) => { const { session } = await authenticate.admin(request); console.log('@ This is the session object: ', session); } but this can be work in backand file? because i tried but nothing get print in server console !!!my backand file path is:app/routes/api.recuring.jsx

*im also using remix app

lizkenyon commented 1 month ago

Hi there 👋

We do have in the migration guide and release notes for these packages, you can review them here.

We have also started a changelog for the template itself so you can easier see the updates to the template. But I would recommend reading the changelog for the packages to understand what is available in new features.

@dkalariya Would you mind creating a new ticket with for your issue and include detailed steps fro reproduction!

dkalariya commented 4 weeks ago

Hi there 👋

We do have in the migration guide and release notes for these packages, you can review them here.

We have also started a changelog for the template itself so you can easier see the updates to the template. But I would recommend reading the changelog for the packages to understand what is available in new features.

@dkalariya Would you mind creating a new ticket with for your issue and include detailed steps fro reproduction!

@lizkenyon i have one query when im call a loader or action function app.jsx which is my remix app main file or in any frontend file data is gettig.but when im access the data using same loader or action function with backand api file(action function ) that time im not abled to get the session.

im also try with your previous day migartion 5.0.0 solution.useOnlinTokens:true.