I used duo_universal_php to add the push notification to my mobile to authorize the user’s login. Once the user try to login to my Laravel platform I needed to add the Duo push notification to verify the login.
I created a Service for this:
class DuoAuthenticationService
{
protected $client;
public function __construct()
{
$this->client = new Client(
config('duo.client_id'),
config('duo.client_secret'),
config('duo.api_hostname'),
config('duo.redirect_uri')
);
}
public function initiateAuthentication($username)
{
$state = $this->client->generateState();
$authUrl = $this->client->createAuthUrl($username, $state);
return $authUrl;
}
}
I got these client_id & secret_id by creating an application in Duo admin panel as Web SDK.
Once I called this initiateAuthentication()
function, it returns following error:
{
"error": "invalid_grant",
"error_description": "Invalid redirect URI 'http://127.0.0.1:8000/duo/callback'."
}
For the redirect URI I added it from .env
as DUO_REDIRECT_URI="http://127.0.0.1:8000/duo/callback"
.
I really appreciate anyone could help me with this please. My project is on Laravel 6.0
& php
version is 7.2