快推365SEO问答正文

百度智能小程序错误码如何解读

2020/12/17 16:56:52

1031浏览量

回答

2020/12/17 16:59:31

百度OAuth2.0在接受验证授权请求时,授权服务器会按照OAuth2.0协议对本次请求参数、请求头部进行检验,若请求不合法或验证未通过,授权服务器会返回相应的错误信息。




错误码返回信息简介

错误码返回方式分两种:


1、在浏览器访问请求授权Endpoint"https://openapi.baidu.com/oauth/2.0/authorize"时返回,直接在浏览器页面上显示错误信息。

2、在应用的服务端访问数据接口,如: 请求Access Token Endpoint"https://openapi.baidu.com/oauth/2.0/token"时返回,返回方式是返回一段JSON文本,包含以下字段:

error:错误码;

error_description:错误描述信息,用来帮助理解和解决发生的错误。



例如:

HTTP/1.1 400 Bad Request

Content-Type: application/json

Cache-Control: no-store


{

  "error": "invalid_grant",

  "error_description": "Invalid authorization code: ANXxSNjwQDugOnqeikRMu2bKaXCdlLxn"




invalid_request    

invalid refresh token    

请求缺少某个必需参数,包含一个不支持的参数或参数值,或者格式不正确。    



invalid_client    

unknown client id    

client_id”、“client_secret”参数无效。    



invalid_grant    

The provided authorization grant is revoked    

提供的Access Grant是无效的、过期的或已撤销的,例如,Authorization Code无效(一个授权码只能使用一次)、Refresh Token无效、redirect_uri与获取Authorization Code时提供的不一致、Devie Code无效(一个设备授权码只能使用一次)等。    

unauthorized_client    

The client is not authorized to use this authorization grant type    

应用没有被授权,无法使用所指定的grant_type。    



unsupported_grant_type    

The authorization grant type is not supported    

“grant_type”百度OAuth2.0服务不支持该参数。    



invalid_scope    

The requested scope is exceeds the scope granted by the resource owner    

请求的“scope”参数是无效的、未知的、格式不正确的、或所请求的权限范围超过了数据拥有者所授予的权限范围。    



expired_token    

refresh token has been used    

提供的Refresh Token已过期    



redirect_uri_mismatch    

Invalid redirect uri    

“redirect_uri”所在的根域与开发者注册应用时所填写的根域名不匹配。    



unsupported_response_type    

The response type is not supported    

“response_type”参数值不为百度OAuth2.0服务所支持,或者应用已经主动禁用了对应的授权模式    



slow_down    

The device is polling too frequently    

Device Flow中,设备通过Device Code换取Access Token的接口过于频繁,两次尝试的间隔应大于5秒。    



authorization_pending    

User has not yet completed the authorization    

Device Flow中,用户还没有对Device Code完成授权操作。    



authorization_declined    

User has declined the authorization  

Device Flow中,用户拒绝了对Device Code的授权操作。    



invalid_referer    

Invalid Referer    

Implicit Grant模式中,浏览器请求的Referer与根域名绑定不匹配    




此教程来源于《搜外网-夫唯SEO培训》,网址:https://www.seowhy.com/

本教程连接:https://www.seowhy.com/a/759.html,为原创表示感谢!


0+1

0+1