(c *gin.Context)
| 13 | ) |
| 14 | |
| 15 | func baiduToken(c *gin.Context) { |
| 16 | code := c.Query("code") |
| 17 | if code == "" { |
| 18 | ErrorStr(c, "no code") |
| 19 | return |
| 20 | } |
| 21 | res, err := RestyClient.R(). |
| 22 | Get(fmt.Sprintf( |
| 23 | "https://openapi.baidu.com/oauth/2.0/token?grant_type=authorization_code&code=%s&client_id=%s&client_secret=%s&redirect_uri=%s", |
| 24 | code, baiduClientId, baiduClientSecret, baiduCallbackUri)) |
| 25 | if err != nil { |
| 26 | Error(c, err) |
| 27 | return |
| 28 | } |
| 29 | JsonBytes(c, res.Bytes()) |
| 30 | } |