I have laravel 5.8 app installed on ubuntu 18( under Digital Ocean ) under domain: https://www.votes.nilov-sergey-demo-apps.tk
I try to implement Google Calendar API in my app and I have control :
app/Http/Controllers/gCalendarController.php
<?php
namespace App\Http\Controllers;
use Carbon\Carbon;
use Google_Client;
use Google_Service_Calendar;
use Google_Service_Calendar_Event;
use Google_Service_Calendar_EventDateTime;
use Illuminate\Http\Request;
class gCalendarController extends Controller
{
protected $client;
public function __construct()
{
$client = new Google_Client();
$client->setAuthConfig('client_secret.json');
$client->addScope(Google_Service_Calendar::CALENDAR);
$guzzleClient = new \GuzzleHttp\Client(array('curl' => array(CURLOPT_SSL_VERIFYPEER => false)));
$client->setHttpClient($guzzleClient);
$this->client = $client;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
session_start();
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$this->client->setAccessToken($_SESSION['access_token']);
$service = new Google_Service_Calendar($this->client);
$calendarId = 'primary';
$results = $service->events->listEvents($calendarId);
return $results->getItems();
} else {
return redirect()->route('oauthCallback');
}
}
with routes :
Route::resource('gcalendar', 'gCalendarController');
Route::get('oauth', ['as' => 'oauthCallback', 'uses' => 'gCalendarController@oauth']);
running index method with url https://www.votes.nilov-sergey-demo-apps.tk/gcalendar I got redirect error :
400. That’s an error.
Error: redirect_uri_mismatch
Request Details
response_type=code
access_type=online
client_id=456883705724-bjk3vme7oo0bf4quno7hkfvaanbc0uej.apps.googleusercontent.com
redirect_uri=https://www.votes.nilov-sergey-demo-apps.tk/oauth
state=
scope=https://www.googleapis.com/auth/calendar
approval_prompt=auto
That’s all we know.
My app options are : https://prnt.sc/oc2c3x Making Oath client ID I Selected "Other" All options with https://www.votes.nilov-sergey-demo-apps.tk.
Why redirect error and how to fix it ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire