Skip to content

Tried to implement grant_type = client_credentials .. not working v6.0 #429

Closed

Description

@fmangat

Bug Report

after migration and applying fixture i had to change the

src\Core\src\Security\src\Entity\OAuthAccessToken.php

#[ORM\Column(name: 'user_id', type: 'string', length: 25, nullable: true)]
private ?string $userId;

To

#[ORM\Column(name: 'user_id', type: 'string', length: 25, nullable: true)]
private ?string $userId=null;

i was able to generate access token but when i tried to access endpoint with bearer token it gave

{
"error": {
"messages": [
"User not found."
]
}
}

and problem was coming because of issue in verification of token .. issue goes if i passed exact jwt token in token column of oauth_access_tokens..

Summary

Current behavior

unable to get "grant_type": "client_credentials", not working out of the box

Activity

  1. alexmerlin commented on Jun 23, 2025

    @alexmerlin
    Member

    Thanks @fmangat!

    The issue you encountered is caused by not using the recommended grant_type=password which makes sure that a user/admin will authenticate using an identity+password combination. Once the user is matched, the identity gets stored into the user_id you mentioned, so it will never be null for successful authentications.

    We built Dotkernel API on the above scenario.
    In your case, using a different grant_type follows a different auth flow, causing the user_id column not getting populated, hence the message User not found.

    Is using grant_type=client_credentials a requirement in your app?

  2. fmangat commented on Jun 23, 2025

    @fmangat
    Author

    DOTKERNEL API should support all grant Types available in oAUTH2.0 , yes grant_type=client_credentials is a requirement.. also please confirm if grant_type = code is working fine for version 6.0

  3. arhimede commented on Jun 24, 2025

    @arhimede
    Member

    @fmangat
    In the past 7 years, we used only grant_type=password, that's why all other grant_types are not tested.

    I am not sure if there is a demand for implementing other grant_types too, probably depends of the business case.
    I am transforming now this issue in discussion, in order to collect feedback from other user too

  4. locked and limited conversation to collaborators on Jun 24, 2025
  5. converted this issue into a discussion #431 on Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions