Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of undefined (reading 'access_token') #5342

Closed
CervarlCG opened this issue Oct 10, 2023 · 4 comments · Fixed by #5406
Closed

Cannot read properties of undefined (reading 'access_token') #5342

CervarlCG opened this issue Oct 10, 2023 · 4 comments · Fixed by #5406

Comments

@CervarlCG
Copy link

CervarlCG commented Oct 10, 2023

Bug report

Cannot read properties of undefined (reading 'access_token')

Describe the bug

When login from store side using the medusa.auth.getToken({email, password}) method i get the error Cannot read properties of undefined (reading 'access_token') from @medusajs/medusa-js package, it seems that the way the package try to access to the data is wrong

This is the raw response from the server

{
    "access_token": "SECRET_ACCESS_TOKEN"
}

System information

Medusa version (including plugins):
Node.js version: 16.16.0
Database: PostgreSQL 15.1 (Ubuntu 15.1-1.pgdg20.04+1) on aarch64-unknown-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit
Operating system: Ubuntu
Browser (if relevant): Chrome (not relevant)

Steps to reproduce the behavior

  1. Use the @medusajs/medusa-js package to try to get token medusa.auth.getToken(/**/)
  2. See error

Expected behavior

Package returns the token

Screenshots

If applicable, add screenshots to help explain your problem

Code snippets

If applicable, add code samples to help explain your problem

Additional context

Add any other context about the problem here

@CervarlCG
Copy link
Author

I think issue is here https://github.com/medusajs/medusa/blob/daea35fe73bf7a3e40e52ca046f7c929688d503c/packages/medusa-js/src/resources/auth.ts#L67C32-L67C32

It should be

JwtTokenManager.registerJwt(res.access_token, "store");

@olivermrbl
Copy link
Contributor

@dPreininger, could you have a look at this?

@dPreininger
Copy link
Contributor

Ill look at it

@olivermrbl
Copy link
Contributor

Thanks! <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants