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

Function dropboxToken

app/dropbox.go:23–64  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

21}
22
23func dropboxToken(c *gin.Context) {
24 var req dropboxTokenReq
25 err := c.ShouldBind(&req)
26 if err != nil {
27 Error(c, err)
28 return
29 }
30 if req.ClientID == "" || req.ClientID == dropboxClientID {
31 req.ClientID = dropboxClientID
32 req.ClientSecret = dropboxClientSecret
33 }
34 form := map[string]string{
35 "grant_type": req.GrantType,
36 "client_id": req.ClientID,
37 "client_secret": req.ClientSecret,
38 //"redirect_uri": req.RedirectUri,
39 //"code": req.Code,
40 //"refresh_token": req.RefreshToken,
41 }
42 if req.RedirectUri != "" {
43 form["redirect_uri"] = req.RedirectUri
44 }
45 switch req.GrantType {
46 case "authorization_code":
47 form["code"] = req.Code
48 case "refresh_token":
49 form["refresh_token"] = req.RefreshToken
50 default:
51 ErrorStr(c, "Incorrect GrantType")
52 return
53 }
54 res, err := RestyClient.R().
55 SetFormData(form).
56 Post("https://api.dropboxapi.com/oauth2/token")
57 if err != nil {
58 Error(c, err, http.StatusInternalServerError)
59 return
60 }
61 c.Status(res.StatusCode())
62 JsonBytes(c, res.Bytes())
63 return
64}

Callers

nothing calls this directly

Calls 3

ErrorFunction · 0.85
ErrorStrFunction · 0.85
JsonBytesFunction · 0.85

Tested by

no test coverage detected