Home > Backend Development > PHP Tutorial > laravel 5.3 api routing keeps prompting Unauthenticated

laravel 5.3 api routing keeps prompting Unauthenticated

WBOY
Release: 2023-03-02 12:34:01
Original
2422 people have browsed it

The route configured in laravel 5.3 route/api.php keeps prompting Unauthenticated. I added _token=xxxx but it doesn’t work either

Reply content:

The route configured in laravel 5.3 route/api.php keeps prompting Unauthenticated. I added _token=xxxx but it doesn’t work either

1. Check whether it is in accordance with passport

<code class="bash">composer require laravel/passport</code>
Copy after login

For configuration, please refer to: API authorization document

2. Modify PassportServiceProvider.php

Modify PassportServiceProvider.php

<code class="php">//将这100year的过期时间!!!!!!!超过2038

$server->enableGrantType(
    new PersonalAccessGrant, new DateInterval('P100Y')
);

//更改为1year

$server->enableGrantType(
    new PersonalAccessGrant, new DateInterval('P1Y')
);</code>
Copy after login

Reason:


<code>4字节也就是32位的存储空间的最大值是2147483647,当时间一秒一秒地跳完2147483647那惊心动魄的最后一秒后,它就会转为负数也就是说时间无效。那一刻的准确的时间为2038年1月18日星期一晚上10时14分7秒,之后所有用到这种“标准时间库”的C语言程序都会碰到时间计算上的麻烦。</code>
Copy after login

<code>这就是2038年问题。
</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template