MCPcopy Create free account
hub / github.com/AlistGo/auth / baiduToken

Function baiduToken

app/baidu.go:15–30  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

13)
14
15func 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}

Callers

nothing calls this directly

Calls 3

ErrorStrFunction · 0.85
ErrorFunction · 0.85
JsonBytesFunction · 0.85

Tested by

no test coverage detected