Cannot auth API Token - invalid_grant

Your software
My Mautic version is: 5.2
My PHP version is: 8.2
My Database type and version is: idk

Your problem
My problem is:
I was trying to integrate with a service, then they told me my api token was invalid. Then tried this command:

curl -X GET “https://my.mautic.address/api/users/me” -H “Authorization: Bearer 7_3iajoynzwhkw000k8sccscocs4sc4w8kwow4k4wcw8ss4sswg4”

Result:
{“errors”:[{“message”:“The access token provided is invalid.”,“code”:401,“type”:“invalid_grant”}]}

Cleaned cache, tried to increase token expire date, create several tokens…

Is this installation necessary to my version? GitHub - mautic/api-library: Mautic API Library

Tried to install it, but got a problem with my server memory, could not install so far. Then tried to add only the lib folder on the base of my mautic, and nothing changed.

Any ideas?

These errors are showing in the log:
No errors on the log :pensive:

Steps I have tried to fix the problem:

Are you sure about your cURL?

This is one of my cURL:

# Mautic URL
MAUTIC="my.mautic.address"

# Mautic administrator
USER="admin"

# Mautic Token
PASSWORD="7_3iajoynzwhkw000k8sccscocs4sc4w8kwow4k4wcw8ss4sswg4"

curl -X GET -u $USER:$PASSWORD   https://$MAUTIC/api/users/self

Hope it will help you.

Thank you for the reply.

Tried like that, but forgot to mention that I need to use Oauth2 for integrating with the service. And your Curl command is HTTP basic auth.

What i want to know is… why fresh created tokens are invalid?
Is there a way to check validity via database? Or is there a way to log information about tokens errors on my log files?

I’ve installed my mautic via softaculous, all working fine, except for this…

Maybe this will help?

Ty for the reply.
Idk why I could integrate for a while with the other system. Token was authorized, could send users to specific segments. Then after a day token stopped working, even setting it to several days.

What is the maximum value i can set on those fields?
Access token lifetime (in minutes)
Refresh token lifetime (in days)

Oh, btw, i saw this topic before. But its from 2015, and my mautic version is 5.2, are those steps useful for 5.2 version?

Well, installed all mautic and api-modules on my pc, then moved vendor folder + composer.lock composer.json to my server. Then deleted all previous integrations on the service I was looking to integrate. Its working… Hope it keeps working for a while now