开源中国 API
  1. 认证接口
开源中国 API
  • OSCHINA 开放平台Beta
  • 认证接口
    • oauth2_authorize
      GET
    • oauth2_token
      POST
  • 个人信息
    • openapi_user
      POST
    • user_information
      POST
    • my_information
      POST
    • portrait_update
      POST
    • friends_list
      POST
    • active_list
      POST
    • update_user_relation
      POST
  • 新闻
    • news_list
      POST
    • /action/openapi/news_detail
      POST
  • 帖子
    • post_list
      POST
    • post_pub
      POST
    • post_detail
      POST
  • 动弹
    • tweet_list
      POST
    • tweet_detail
      POST
    • tweet_pub
      POST
    • tweet_delete
      POST
  • 博客
    • blog_pub
      POST
    • blog_list
      POST
    • blog_recommend_list
      POST
    • blog_detail
      POST
    • user_blog_list
      POST
    • blog_catalog_list
      POST
  • 评论
    • blog_comment_list
    • blog_comment_pub
    • blog_comment_reply
    • user_blog_delete
    • comment_list
    • comment_pub
    • comment_reply
    • comment_delete
  • 收藏
    • favorite_list
    • favorite_add
    • favorite_remove
  • 软件
    • project_detail
    • project_catalog_list
    • project_list
    • project_tag_list
  • 私信
    • message_list
    • message_delete
  • 搜索
    • search_list
  • 通知
    • user_notice
    • clear_notice
  1. 认证接口

oauth2_token

POST
/action/openapi/token
支持格式:JSON JSONP XML
HTTP请求方式:GET/POST
错误说明
错误代码错误标识说明
400invalid_request无效请求(缺少必要参数)
401invalid_clientclient_id无效
401invalid_grant授权方式无效
401unauthorized_client应用未授权
401unsupported_grant_type不支持的授权方式
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://www.oschina.net/action/openapi/token' \
--header 'Content-Type: application/json' \
--data-raw '{
    "client_id": "string",
    "client_secret": "string",
    "grant_type": "string",
    "redirect_uri": "string",
    "code": "string",
    "refresh_token": "string",
    "dataType": "string",
    "callback": "string"
}'
响应示例响应示例
{
  "access_token": "8447ff97-9b8c-4224-9cec-63b97d34ba65",
  "refresh_token": "8447ff97-9b8c-4224-9cec",
  "token_type": "bearer",
  "expires_in": 43199,
  "uid": 12
}

请求参数

Body 参数application/json
client_id
string 
必需
OAuth2客户ID
client_secret
string 
OAuth2密钥
必需
grant_type
string 
必需
授权方式:authorization_code或者refresh_token
redirect_uri
string 
回调地址
必需
code
string 
必需
调用 /action/oauth2/authorize 接口返回的授权码(grant_type为authorization_code时必选)
refresh_token
string 
可选
上次调用 /action/oauth2/token 接口返回的refresh_token(grant_type为refresh_token时必选)
dataType
string 
必需
返回数据类型['json'|'jsonp'|'xml']
callback
string 
可选
dataType为 jsonp 时用来指定回调函数
示例

返回响应

🟢200成功
application/json
Body
access_token
string 
必需
access_token值
refresh_token
string 
必需
refresh_token值
token_type
string 
必需
access_token类型
expires_in
integer 
超时时间(单位秒)
必需
uid
integer 
授权用户的uid
必需
修改于 2022-08-22 04:12:00
上一页
oauth2_authorize
下一页
openapi_user
Built with