"ACCESS_DENIED Error When Requesting Access Token via Open API"
"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
, andredirect_uri
are all taken directly from my cTrader Open API application.- I have verified that the
client_id
andclient_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
- URL:
Steps Taken:
- I’ve ensured that my
client_id
andclient_secret
are correctly copied from my application. - I’ve matched the
redirect_uri
with the one specified in my application settings. - I have tried multiple authorization codes, ensuring that they are freshly generated.
- 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
Replies
Vasilios-G
17 Nov 2024, 15:16
( Updated at: 17 Nov 2024, 16:38 )
RE: "ACCESS_DENIED Error When Requesting Access Token via Open API"
PanagiotisCharalampous said:
Hi Vasilie,
Try using https://openapi.ctrader.com/apps/token to retrieve the token and let me know if this works.
Best regards,
Panagiotis
Hi Panagiotis,
Thank you for your reply.
I’ve tried using the suggested URL https://openapi.ctrader.com/apps/token in almost every possible place in my code, including replacing both the auth_url
and token_url
:
python
Code kopieren
# URLs for authentication and token retrieval
self.auth_url = 'https://openapi.ctrader.com/apps/auth'
self.token_url = 'https://openapi.ctrader.com/apps/token'
Unfortunately, despite these efforts, I’m still getting the "ACCESS_DENIED" error when trying to retrieve the access token.
Is there a specific way or place where this URL is supposed to be used that I might be missing? Also, would it be possible for someone to review my code or point out any common pitfalls I might be encountering?
Ελπίζω ειλικρινά να μπορέσετε να με βοηθήσετε περαιτέρω. Η υποστήριξή σας είναι ανεκτίμητη!
Με εκτίμηση,
Vasilios Gerasimou
@Vasilios-G
PanagiotisCharalampous
17 Nov 2024, 16:47
RE: RE: "ACCESS_DENIED Error When Requesting Access Token via Open API"
Vasilios-G said:
PanagiotisCharalampous said:
Hi Vasilie,
Try using https://openapi.ctrader.com/apps/token to retrieve the token and let me know if this works.
Best regards,
Panagiotis
Hi Panagiotis,
Thank you for your reply.
I’ve tried using the suggested URL https://openapi.ctrader.com/apps/token in almost every possible place in my code, including replacing both the
auth_url
andtoken_url
:python
Code kopieren
# URLs for authentication and token retrieval self.auth_url = 'https://openapi.ctrader.com/apps/auth' self.token_url = 'https://openapi.ctrader.com/apps/token'
Unfortunately, despite these efforts, I’m still getting the "ACCESS_DENIED" error when trying to retrieve the access token.
Is there a specific way or place where this URL is supposed to be used that I might be missing? Also, would it be possible for someone to review my code or point out any common pitfalls I might be encountering?
Ελπίζω ειλικρινά να μπορέσετε να με βοηθήσετε περαιτέρω. Η υποστήριξή σας είναι ανεκτίμητη!
Με εκτίμηση,
Vasilios Gerasimou
Hi Vasilie,
Can you share a video demonstrating the exact steps you follow to receive this error, as well as the exact link for which the access is denied?
Best regards,
Panagiotis
@PanagiotisCharalampous
Vasilios-G
18 Nov 2024, 19:22
( Updated at: 19 Nov 2024, 06:35 )
RE: RE: RE: "ACCESS_DENIED Error When Requesting Access Token via Open API"
PanagiotisCharalampous said:
Vasilios-G said:
PanagiotisCharalampous said:
Hi Vasilie,
Try using https://openapi.ctrader.com/apps/token to retrieve the token and let me know if this works.
Best regards,
Panagiotis
Hi Panagiotis,
Thank you for your reply.
I’ve tried using the suggested URL https://openapi.ctrader.com/apps/token in almost every possible place in my code, including replacing both the
auth_url
andtoken_url
:python
Code kopieren
# URLs for authentication and token retrieval self.auth_url = 'https://openapi.ctrader.com/apps/auth' self.token_url = 'https://openapi.ctrader.com/apps/token'
Unfortunately, despite these efforts, I’m still getting the "ACCESS_DENIED" error when trying to retrieve the access token.
Is there a specific way or place where this URL is supposed to be used that I might be missing? Also, would it be possible for someone to review my code or point out any common pitfalls I might be encountering?
Ελπίζω ειλικρινά να μπορέσετε να με βοηθήσετε περαιτέρω. Η υποστήριξή σας είναι ανεκτίμητη!
Με εκτίμηση,
Vasilios Gerasimou
Hi Vasilie,
Can you share a video demonstrating the exact steps you follow to receive this error, as well as the exact link for which the access is denied?
Best regards,
Panagiotis
Here the proceed frame by frame:
i click on the link:
copy the access token and paste it here:
After pressing the enter button:
This is what it looks like when I use the link you provided, or rather, an error already appears on the page where I retrieve the token.
Regards, Vasili.
@Vasilios-G
PanagiotisCharalampous
19 Nov 2024, 07:06
RE: RE: RE: RE: "ACCESS_DENIED Error When Requesting Access Token via Open API"
Vasilios-G said:
PanagiotisCharalampous said:
Vasilios-G said:
PanagiotisCharalampous said:
Hi Vasilie,
Try using https://openapi.ctrader.com/apps/token to retrieve the token and let me know if this works.
Best regards,
Panagiotis
Hi Panagiotis,
Thank you for your reply.
I’ve tried using the suggested URL https://openapi.ctrader.com/apps/token in almost every possible place in my code, including replacing both the
auth_url
andtoken_url
:python
Code kopieren
# URLs for authentication and token retrieval self.auth_url = 'https://openapi.ctrader.com/apps/auth' self.token_url = 'https://openapi.ctrader.com/apps/token'
Unfortunately, despite these efforts, I’m still getting the "ACCESS_DENIED" error when trying to retrieve the access token.
Is there a specific way or place where this URL is supposed to be used that I might be missing? Also, would it be possible for someone to review my code or point out any common pitfalls I might be encountering?
Ελπίζω ειλικρινά να μπορέσετε να με βοηθήσετε περαιτέρω. Η υποστήριξή σας είναι ανεκτίμητη!
Με εκτίμηση,
Vasilios Gerasimou
Hi Vasilie,
Can you share a video demonstrating the exact steps you follow to receive this error, as well as the exact link for which the access is denied?
Best regards,
Panagiotis
Here the proceed frame by frame:
i click on the link:
copy the access token and paste it here:
After pressing the enter button:
This is what it looks like when I use the link you provided, or rather, an error already appears on the page where I retrieve the token.
Regards, Vasili.
Hi there,
It seems you are using the access token instead of the authorization code. You need to use the authorization code returned by the authorization url when it redirects back to the redirect uri.
Best regards,
Panagiotis
@PanagiotisCharalampous
Vasilios-G
19 Nov 2024, 19:28
( Updated at: 20 Nov 2024, 06:50 )
RE: RE: RE: RE: RE: "ACCESS_DENIED Error When Requesting Access Token via Open API"
PanagiotisCharalampous said:
Vasilios-G said:
PanagiotisCharalampous said:
Vasilios-G said:
PanagiotisCharalampous said:
Hi Vasilie,
Try using https://openapi.ctrader.com/apps/token to retrieve the token and let me know if this works.
Best regards,
Panagiotis
Hi Panagiotis,
Thank you for your reply.
I’ve tried using the suggested URL https://openapi.ctrader.com/apps/token in almost every possible place in my code, including replacing both the
auth_url
andtoken_url
:python
Code kopieren
# URLs for authentication and token retrieval self.auth_url = 'https://openapi.ctrader.com/apps/auth' self.token_url = 'https://openapi.ctrader.com/apps/token'
Unfortunately, despite these efforts, I’m still getting the "ACCESS_DENIED" error when trying to retrieve the access token.
Is there a specific way or place where this URL is supposed to be used that I might be missing? Also, would it be possible for someone to review my code or point out any common pitfalls I might be encountering?
Ελπίζω ειλικρινά να μπορέσετε να με βοηθήσετε περαιτέρω. Η υποστήριξή σας είναι ανεκτίμητη!
Με εκτίμηση,
Vasilios Gerasimou
Hi Vasilie,
Can you share a video demonstrating the exact steps you follow to receive this error, as well as the exact link for which the access is denied?
Best regards,
Panagiotis
Here the proceed frame by frame:
i click on the link:
copy the access token and paste it here:
After pressing the enter button:
This is what it looks like when I use the link you provided, or rather, an error already appears on the page where I retrieve the token.
Regards, Vasili.
Hi there,
It seems you are using the access token instead of the authorization code. You need to use the authorization code returned by the authorization url when it redirects back to the redirect uri.
Best regards,
Panagiotis
Hi there,
when i do it like this:
i get the same error. Can you explain it to me step by step.
@Vasilios-G
PanagiotisCharalampous
20 Nov 2024, 07:12
RE: RE: RE: RE: RE: RE: "ACCESS_DENIED Error When Requesting Access Token via Open API"
Vasilios-G said:
PanagiotisCharalampous said:
Vasilios-G said:
PanagiotisCharalampous said:
Vasilios-G said:
PanagiotisCharalampous said:
Hi Vasilie,
Try using https://openapi.ctrader.com/apps/token to retrieve the token and let me know if this works.
Best regards,
Panagiotis
Hi Panagiotis,
Thank you for your reply.
I’ve tried using the suggested URL https://openapi.ctrader.com/apps/token in almost every possible place in my code, including replacing both the
auth_url
andtoken_url
:python
Code kopieren
# URLs for authentication and token retrieval self.auth_url = 'https://openapi.ctrader.com/apps/auth' self.token_url = 'https://openapi.ctrader.com/apps/token'
Unfortunately, despite these efforts, I’m still getting the "ACCESS_DENIED" error when trying to retrieve the access token.
Is there a specific way or place where this URL is supposed to be used that I might be missing? Also, would it be possible for someone to review my code or point out any common pitfalls I might be encountering?
Ελπίζω ειλικρινά να μπορέσετε να με βοηθήσετε περαιτέρω. Η υποστήριξή σας είναι ανεκτίμητη!
Με εκτίμηση,
Vasilios Gerasimou
Hi Vasilie,
Can you share a video demonstrating the exact steps you follow to receive this error, as well as the exact link for which the access is denied?
Best regards,
Panagiotis
Here the proceed frame by frame:
i click on the link:
copy the access token and paste it here:
After pressing the enter button:
This is what it looks like when I use the link you provided, or rather, an error already appears on the page where I retrieve the token.
Regards, Vasili.
Hi there,
It seems you are using the access token instead of the authorization code. You need to use the authorization code returned by the authorization url when it redirects back to the redirect uri.
Best regards,
Panagiotis
Hi there,
when i do it like this:
i get the same error. Can you explain it to me step by step.
Hi Vasilie,
For step by step instructions you should contact the script developer, I don't know what it does and how it should be used. What I see in the screenshots is that the application is asking for the authorization code but you are passing the token instead. The authorization code and the token are two different things.
Best regards,
Panagiotis
@PanagiotisCharalampous
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