Laravel Passport 学习整理

四种模式使用总结

file

注意和备注说明

  • 请求前认证用户:比如我们在使用weibo和QQ第三方登录时,要求先登录weibo和qq后在授权。
  • code:有效期默认为十分钟。
  • redirect_uri:必须和创建client_id的redirect_uri一模一样,否则会错误,发送请求时可以不填该参数.
  • state:用来传递跳转链接跟其他参数,使用前encode一下传递。
  • url#hash参数传递 :原因说明

使用中的错误与解决办法

请求code时,弹出HTTP Basic认证框
file

用code获取access_token时,GuzzleHttp\Exception\ServerException (500)。

Server error: POST http://myhost/oauth/token resulted in a 500 Internal Server Error response: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mydb5.5.oauth_clients' doesn't exist (SQL: select * from oau
file

用code获取access_token时,GuzzleHttp\Exception\ClientException (401)

Client error: POST http://myhost/oauth/token resulted in a 401 Unauthorized response: {"error":"invalid_client","message":"Client authentication failed"}
file

用code获取access_token时,GuzzleHttp\Exception\ClientException (400)

Client error: POST http://myhost/oauth/token resulted in a 400 Bad Request response:
{"error":"invalid_request","message":"The request is missing a required parameter, includes an invalid parameter value
file

本作品采用《CC 协议》,转载必须注明作者和本文链接
本帖由 Summer 于 6年前 加精
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
讨论数量: 9
幽弥狂
{
"error": "invalid_client",
"message": "Client authentication failed"
}

输入:
php artisan passport:client --password

file

5年前 评论

其实我一直想说,密码模式下应该暴露一个token的对内接口,用http请求对外接口获取token会影响性能吧

6年前 评论

@skyjerry 第一次获取到,会根据有效期,缓存起来,过期后在申请新的或者刷新access_token

6年前 评论

@xjpeng 嗯嗯这个我知道,我在进行微信小程序开发时,需要用 open_id 获取token,只能用http请求http接口获取token返回给微信端,让我很难受?

6年前 评论

请求令牌# 授权时的重定向#
请问。这情况是?有解决的办法么,谢谢

file

6年前 评论
直面苦痛的人生 4年前
直面苦痛的人生 4年前

@a蒜 你是不是没有执行php artisan make:auth,现在感觉是你授权前没有登录,系统要跳转到登录页面,你的这路由没有配置

6年前 评论

请问一下,开发微信小程序,并不是通过用户名和密码登录,那么所有的请求接口安全问题,到底用哪种模式好?

6年前 评论
直面苦痛的人生 4年前

@xjpeng 你说的没有错,谢谢

6年前 评论

{"error":"invalid_client","message":"Client authentication failed"}
这个错误,确认数据库是对上的。然后日志错误如下,大神,怎么解

local.ERROR: The authorization grant type is not supported by the authorization server. {"userId":2,"exception":"[object] (League\OAuth2\Server\Exception\OAuthServerException(code: 2): The authorization grant type is not supported by the authorization server. at /Users/hantian/Desktop/jushi_laravel/vendor/league/oauth2-server/src/Exception/OAuthServerException.php:65)

6年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!