Authorisation Error Error 400: invalid_request saat ingin membuat API Login with Google

Saya mau buat pilihan "Login with Google" dengan API. Lalu setelah saya mengklik button Login dengan Akun Google" itu muncul error seperti ini
Authorisation Error
Error 400: invalid_requestInvalid parameter value for approval_prompt: 'auto'' is not valid. Gimana ya benerinnya?ยIni kodenyaย
<?php
require_once 'vendor/autoload.php';
$clientID='340784022267-s1h4l6gsabreff04ms37bbi53ie3iuno.apps.googleusercontent.com';
$clientSecret='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';
$redirectUrl = "http://localhost/glogin/login.php";
// membuat client request ke google
$client = new Google_Client();
$client->setClientId($clientID);
$client->setClientSecret($clientSecret);
$client->setRedirectUri($redirectUrl);
$client->addScope('profile');
$client->addScope('email');
if(isset($_GET['code'])){ $token=$client->fetchAccessTokenWithAuthCode($_GET['code']); $client->setAccessToken($token);
ย ย //Mendapatkan user profile $gauth = new Google_Service_Oauth2($client); $google_info = $gauth->userinfo->get(); $email = $google_info->email; $name = $google_info->name;
echo "Selamat Datang " .$name. " Anda telah terdaftar menggunakan email : " .$email;} else{ echo "<a href=".$client->createAuthUrl()."'>Login dengan akun Google</a>"; }
berikut link video tutorial yang saya ikuti https://www.youtube.com/watch?v=i5IybpgcInY&t=1s
atau respon:
Jawaban
coba dengan menambahkan
Informasi
https://developers.google.com/identity/protocols/oauth2/openid-connect#authenticationuriparameters
$client->setPrompt('consent');
Informasi
https://developers.google.com/identity/protocols/oauth2/openid-connect#authenticationuriparameters

2463 Kontribusi 2031 Poin
Login untuk gabung berdiskusi
Pertanyaan Lainnya
Top Kontributor
- @ahanafi
792 Kontribusi 523 Poin
- @Nandar
647 Kontribusi 204 Poin
- @dianarifr
642 Kontribusi 316 Poin
- @Saputroandhi
509 Kontribusi 162 Poin
- @dodipsitorus
412 Kontribusi 145 Poin