"ACCESS_DENIED Error When Requesting Access Token via Open API"

Created at 15 Nov 2024, 15:20
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
VA

Vasilios-G

Joined 01.11.2024

"ACCESS_DENIED Error When Requesting Access Token via Open API"
15 Nov 2024, 15:20


Hello cTrader Community,

I am currently working on a trading bot project using the cTrader Open API. I am facing a persistent issue when trying to retrieve an access token using my client_id and client_secret. Here is a summary of my problem:

Problem Description:

  • I successfully open the authorization URL in the browser and receive the authorization code.
  • However, when I use this code to request an access token, I keep receiving the following error response:
  • The status code of the response is 200, but the access token is not returned.

Debug Information:

  • client_id, client_secret, and redirect_uri are all taken directly from my cTrader Open API application.
  • I have verified that the client_id and client_secret are correct, and the redirect URI matches the one registered in the developer portal.
  • I have also tried both the "Account info" and "Account info and trading" scopes, but the error persists.

Request Details:

  • Authorization URL: I can successfully generate this URL and get the authorization code.
  • Token Request:
    • URL: https://connect.spotware.com/apps/token
    •  

Steps Taken:

  1. I’ve ensured that my client_id and client_secret are correctly copied from my application.
  2. I’ve matched the redirect_uri with the one specified in my application settings.
  3. I have tried multiple authorization codes, ensuring that they are freshly generated.
  4. I’ve also experimented with embedding the credentials directly in the code, but the result is the same.

Request for Help:

  • Has anyone encountered this "ACCESS_DENIED" error before when using valid credentials?
  • Are there any specific requirements or common pitfalls with the cTrader Open API authentication process that I may be missing?
  • Any advice or pointers on what else I could try would be greatly appreciated.

Thank you for taking the time to help!

Best regards,
Vasilios Gerasimou


 


@Vasilios-G
Replies

PanagiotisCharalampous
16 Nov 2024, 11:40

Hi Vasilie,

Try using https://openapi.ctrader.com/apps/token to retrieve the token and let me know if this works.

Best regards,

Panagiotis


@PanagiotisCharalampous