Problem with login api

Hey, I am trying to access the login api to generate authentication token but getting an error

Response Code: 401 Response Data: {“status”:“error”,“errors”:[{“errorCode”:“UDAPI100057”,“message”:“Invalid Auth code”,“propertyPath”:null,“invalidValue”:null,“error_code”:“UDAPI100057”,“property_path”:null,“invalid_value”:null}]}

I have taken the example code from Get Token | Upstox Developer API PHP version

$url = ‘https://api.upstox.com/v2/login/authorization/token’;

$headers = [
‘accept: application/json’,
‘Content-Type: application/x-www-form-urlencoded’,
];

$data = [
‘code’ => ‘tgpp123’,
‘client_id’ => ‘50b3a8eb-c301-499c-8843-c64ac3f6b008’,
‘client_secret’ => ‘iscacl157e’,
‘redirect_uri’ => ‘REdirectURL’,
‘grant_type’ => ‘authorization_code’,
];

Please guide what to do.

The error message you received indicates that the authentication code you are using is invalid. Please regenerate your authentication code, as it is important to note that the code is valid for one-time use only.

Also please refer API Documentation | Authentication for more information.

Thank you.

So when I tried this Authentication API it gives me this error message

Please enable cookies.

Sorry, you have been blocked## You are unable to access upstox.com

Why have I been blocked?

This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.

What can I do to resolve this?

You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.

Cloudflare Ray ID: 8bcac2ae5f142c67 • Your IP: 162.241.123.164 • Performance & security by Cloudflare

1

Even at the end it returns 1

I don’t know if I am doing anything wrong. Here is my code:

$apiUrl = "https://api.upstox.com/v2/login/authorization/dialog?response_type=code&client_id=50b3a8eb-c301-499c-8843-c64ac3f6b008&redirect_uri=https://tradesetup.today/app/readups.php";

$ch = curl_init($apiUrl);
$response = curl_exec($ch);
if(curl_errno($ch)) {
    echo 'cURL error: ' . curl_error($ch);
} else {
    $responseData = json_decode($response, true);
    print_r($responseData);
}
curl_close($ch);