Question

I can't redirect

  • 23 February 2024
  • 3 replies
  • 133 views

I need to develop an application with the Calendly api, but instead of redirecting me in the auth process, it constantly refreshes the Connect to Calendly page. My code is as follows

include "./calendly.php";
include "./config.php";
$redirectUrl = "http://localhost/calendly";

header("Location: https://auth.calendly.com/oauth/authorize?client_id=".$clientID ."&response_type=code&redirect_uri=".$redirectUrl."");


if(isset($_GET["code"])){
$calendly = new calendly($clientSecretKey,$clientID,$redirectUrl);
// $code = $calendly->getAuthCode();
var_dump($code);
}

 


3 replies

Hello! Thank you for reaching out.

It appears that you’re trying to create a production oauth application, correct? If so, the redirectUrl must use the HTTPS protocol, not HTTP. If this is a sandbox app, your url would work. Can you elaborate here? Do you see any console errors?

Hello,

First of all, thank you for your feedback. My application is running as a sandbox and there are no errors on the console. I see the redirect url with the code get key on the network movements, but it does not redirect me back. I am writing code with php 8.x version. If you need different details that you want me to share and will help, I can share them. Thank you again for your time.

You’re very welcome. Happy to help.

 

It may be that you need to set the location in an ELSE statement; otherwise, it’s always getting set, and the script will always redirect. Here’s a reference that describes this “Location:” header.

I hope this helps!

Reply