Skip to content

Usernames with Underscores cant use the API? #39781

Open
@BobHelper

Description

@BobHelper

Preconditions and environment

  • Magento version - 2.4.7-p4
  • It seems a user with an underscore in their username cant use the API to get token

Steps to reproduce

Create an API integration to retrieve something simple using a cURL
Create a user with an underscore in the username i.e. john_smith
Create a role to use the API

Try: curl -X POST "https://examplemagentosite.com/rest/V1/integration/admin/token" -H "Content-Type: application/json" -d "{"username":"APIUser_2025", "password":"e.g.password1"}"
Returns: {"message":"The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later."}

Then change the username in Magento back-end and remove the underscore. Re-run with the new username:

But this: curl -X POST "https://examplemagentosite.com/rest/V1/integration/admin/token" -H "Content-Type: application/json" -d "{"username":"APIUser2025", "password":"e.g.password1"}"
"returns the access token that we need"

Expected result

curl -X POST "https://examplemagentosite.com/rest/V1/integration/admin/token" -H "Content-Type: application/json" -d "{"username":"APIUser_2025", "password":"e.g.password1"}"
"returns the access token that we need"

Thats what I expected.

Actual result

This is what you get if the username has an underscore:

Try: curl -X POST "https://examplemagentosite.com/rest/V1/integration/admin/token" -H "Content-Type: application/json" -d "{"username":"APIUser_2025", "password":"e.g.password1"}"
Returns: {"message":"The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later."}

Additional information

No response

Release note

Whilst not severe, this does require a workaround to remove the underscore. I have had a quick dig around but can't find any reference to not using underscores in User Names and if it is an issue then underscores should not be permitted when creating a username?

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Ready for Grooming

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions