简体   繁体   English

如果输入错误的令牌,Google oauth会给出500 Internal Server Error

[英]Google oauth gives 500 Internal Server Error if entered wrong token

Here is my code 这是我的代码

$client = new Google_Client();
$client->setApplicationName("name");
$client->setClientId('id');
$client->setClientSecret('secret');
$client->addScope("https://www.googleapis.com/auth/userinfo.email");
$token_data = $client->verifyIdToken($token);

verifyIdToken is triggering 500 Internal Server Error if token is invalid. 如果令牌无效,则verifyIdToken会触发500 Internal Server Error。 Can you help me to figure out how to get rid of that? 您能帮我找出解决方法吗? And how can i verify the token is valid or not? 我如何验证令牌是否有效?

Never mind. 没关系。

I had to use try-catch to catch exceptions. 我不得不使用try-catch来捕获异常。 If token is invalid, it will trigger an exception. 如果令牌无效,则会触发异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM