1.授權碼(authorization_code)獲取接口
請求地址:https://account.xiaomi.com/oauth2/authorize
請求方法:GET
請求參數(shù):
返回值:
·成功響應
如果授權成功,授權服務器會將用戶的瀏覽器重定向到redirect_uri,并帶上相關參數(shù):
http://example.com/example?code=CODE&state=STATE
返回值說明:
·失敗響應
如果授權失敗,授權服務器會將用戶的瀏覽器重定向到redirect_uri,并帶上相關參數(shù):
http://example.com/example?error=ERROR&error_description=ERROR_DESCRIPTION&state=STATE
返回值說明:
2.獲取訪問令牌(access_token)
請求地址:https://account.xiaomi.com/oauth2/token
請求方法:GET
請求參數(shù):
返回值:
·成功響應
如果請求成功,授權服務器會返回JSON格式的字符串:
返回值示例:
&&&START&&& {
"access_token": "access token value",
"expires_in": 259200,
"refresh_token": "refresh token value",
"scope": "scope value",
"token_type ": "mac",
"mac_key ": "mac key value",
"mac_algorithm": "HmacSha1",
"openId":"2.0XXXXXXXXX"
}
注意:前面的&&&START&&&可以直接去掉。
·失敗響應
如果請求失敗,授權服務器會返回JSON格式的字符串:
返回值示例:
&&&START&&&{
"error": "error_code",
"error_description": "錯誤描述"
}
注意: 前面的 &&&START&&& 可以直接去掉。