I'm following the documentation in regards to generating an Access Token using OAuth Client Credentials flow, from the following link. However, on providing the below HTTP POST request, it returns a HTML body of a login page and not the expected JSON response containing the Access Token. It appears to be the correct end-point, because I receive a HTML page of a 405 error when using GET method instead - which is expected, aside from it returning in HTML as well.
Is this a known issue, or am I going wrong somewhere?
curl --location --request POST 'http://example.com/oauth2-token' \
--header 'Content-Type: application/json' \
--data-raw '{
"grant_type": "client_credentials",
"client_id": "xxxxx",
"client_secret": "xxxxxx"
}
Furthermore, the API is enabled in the configuration, and the initialization of the OAuth with generating an encryption key has also been completed.
OroCommerce is running 4.1.1 on CentOS with Nginx (via Azure Marketplace)
As stated by Andrey Yatsenko above, this issue is caused by a bug from disabling "Guest Mode" in System -> Configuration -> Guest Mode. The API is returning the login page from guest mode being disabled. By enabling Guest Mode, the end-point returns the JSON as expected.