API Response always: : code is invalid or expired

45 views
Skip to first unread message

Muhammad Iqbal

unread,
Aug 3, 2021, 12:26:37 PM8/3/21
to Eventbrite Developers
Hi,

Following is my PHP Code:


$curl = curl_init();
$auth_data = array(
'client_id' => CLIENT_ID,
'client_secret' => CLIENT_SECRET,
        'code'              => PRIVATE_TOKEN,
'grant_type' => 'authorization_code',
         'redirect_url'      => 'www.fff.com',
);

curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $auth_data);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($curl, CURLOPT_URL, $request_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC)

$result = curl_exec($curl);
if(!$result){die("Connection Failure");}
curl_close($curl);
echo $result;

but always getting the same response:

{"error_description":"code is invalid or expired","error":"invalid_grant"}

I have confirmed my auth_data  multiple times.
But always getting above response.

Can any one help me.
Thanks.


nata...@eventbrite.com

unread,
Aug 11, 2021, 6:36:32 PM8/11/21
to Eventbrite Developers
Hi Muhammad!

If you only need to access your own account's data, you can just use your private token (Auth header or query parameter)

If you are hoping to set up an OAuth flow so users can authenticate your application to access their data, review the steps in our API reference here and be sure you are following this step first, so you receive an access code: 

A. Redirect users to our authorization URL, while including your API key and redirect URI as query parameters: https://www.eventbrite.com/oauth/authorize?response_type=code&client_id=YOUR_API_KEY&redirect_uri=YOUR_REDIRECT_URI

You will need to obtain an access code as described above for your 'code' value, rather than your private token.

I hope this is helpful!

Best,
Natalie
Reply all
Reply to author
Forward
0 new messages