why am I getting an "invalid_request"?

607 Views Asked by At

I am trying to use FusionAuth's passwordless login feature. I am getting an error "Invalid redirect uri", when I try clicking on the link in the received email. I am using the php client.

    $request = array();
    $request["applicationId"] = $_SESSION['applicationID'];
    $request["loginId"] = $email;
    $target="http://8615582f3e2c.ngrok.io/index.php/Configure/MyFormEmployees";
    $request["state"]["redirect_uri"] = $target;
    $request["state"]["client_id"]=$_SESSION['applicationID'];
    $request["state"]["response_type"]= "code";
    $request["state"]["scope"]= "openid";
    $request["state"]["state"]= "CSRF123";
    $requestJ = json_encode($request);   //convert the array into json

    $result = $_SESSION['client']->startPasswordlesslogin($requestJ);

And this is what I am getting in the email as a link: http://localhost:9011/oauth2/passwordless/5NHh37raOrUpSO4TlJcL-pY39i1TdasNd9vTTqqaiLk?tenantId=34303566-6466-3234-6565-656233663263&client_id=32688330-1630-4e0d-a4de-8ae45c3ca527&redirect_uri=http%3A%2F%2FXX15582f3e2c.ngrok.io%2Findex.php%2FConfigure%2FMyFormEmployees&response_type=code&scope=openid&state=CSRF123

and this causes the invalid URI error. How can I get this link to work?

1

There are 1 best solutions below

1
On

You'll need to add http://XX15582f3e2c.ngrok.io/index.php/Configure/MyFormEmployees to the list of Authorized redirect URIs. In the FusionAuth console, see Applications > Edit > OAuth > Authorized redirect URLs.