mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-09 20:05:54 +08:00
parent
5dfb4def56
commit
c289a5f14f
2 changed files with 1 additions and 13 deletions
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -92,7 +91,6 @@ func (g *googleDriveClient) Upload(src, target string) (bool, error) {
|
||||||
}
|
}
|
||||||
urlItem := "https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&supportsAllDrives=true"
|
urlItem := "https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&supportsAllDrives=true"
|
||||||
client := resty.New()
|
client := resty.New()
|
||||||
client.SetProxy("http://127.0.0.1:7890")
|
|
||||||
resp, err := client.R().
|
resp, err := client.R().
|
||||||
SetHeader("Authorization", "Bearer "+g.accessToken).
|
SetHeader("Authorization", "Bearer "+g.accessToken).
|
||||||
SetBody(data).
|
SetBody(data).
|
||||||
|
|
@ -220,12 +218,7 @@ func (g *googleDriveClient) handleDownload(urlItem string, target string) error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
req.Header.Add("Authorization", "Bearer "+g.accessToken)
|
req.Header.Add("Authorization", "Bearer "+g.accessToken)
|
||||||
proxyURL, _ := url.Parse("http://127.0.0.1:7890")
|
client := &http.Client{}
|
||||||
client := &http.Client{
|
|
||||||
Transport: &http.Transport{
|
|
||||||
Proxy: http.ProxyURL(proxyURL),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
defer client.CloseIdleConnections()
|
defer client.CloseIdleConnections()
|
||||||
response, err := client.Do(req)
|
response, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -343,7 +336,6 @@ type reqCallback func(req *resty.Request)
|
||||||
|
|
||||||
func (g *googleDriveClient) googleRequest(urlItem, method string, callback reqCallback, resp interface{}) ([]byte, error) {
|
func (g *googleDriveClient) googleRequest(urlItem, method string, callback reqCallback, resp interface{}) ([]byte, error) {
|
||||||
client := resty.New()
|
client := resty.New()
|
||||||
client.SetProxy("http://127.0.0.1:7890")
|
|
||||||
req := client.R()
|
req := client.R()
|
||||||
req.SetHeader("Authorization", "Bearer "+g.accessToken)
|
req.SetHeader("Authorization", "Bearer "+g.accessToken)
|
||||||
if callback != nil {
|
if callback != nil {
|
||||||
|
|
@ -374,7 +366,6 @@ type googleTokenRes struct {
|
||||||
|
|
||||||
func RefreshGoogleToken(grantType string, tokenType string, varMap map[string]interface{}) (string, error) {
|
func RefreshGoogleToken(grantType string, tokenType string, varMap map[string]interface{}) (string, error) {
|
||||||
client := resty.New()
|
client := resty.New()
|
||||||
client.SetProxy("http://127.0.0.1:7890")
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"client_id": loadParamFromVars("client_id", varMap),
|
"client_id": loadParamFromVars("client_id", varMap),
|
||||||
"client_secret": loadParamFromVars("client_secret", varMap),
|
"client_secret": loadParamFromVars("client_secret", varMap),
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ func (g *googleDriveClient) Upload(src, target string) (bool, error) {
|
||||||
}
|
}
|
||||||
urlItem := "https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&supportsAllDrives=true"
|
urlItem := "https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&supportsAllDrives=true"
|
||||||
client := resty.New()
|
client := resty.New()
|
||||||
client.SetProxy("http://127.0.0.1:7890")
|
|
||||||
resp, err := client.R().
|
resp, err := client.R().
|
||||||
SetHeader("Authorization", "Bearer "+g.accessToken).
|
SetHeader("Authorization", "Bearer "+g.accessToken).
|
||||||
SetBody(data).
|
SetBody(data).
|
||||||
|
|
@ -225,7 +224,6 @@ type reqCallback func(req *resty.Request)
|
||||||
|
|
||||||
func (g *googleDriveClient) googleRequest(urlItem, method string, callback reqCallback, resp interface{}) ([]byte, error) {
|
func (g *googleDriveClient) googleRequest(urlItem, method string, callback reqCallback, resp interface{}) ([]byte, error) {
|
||||||
client := resty.New()
|
client := resty.New()
|
||||||
client.SetProxy("http://127.0.0.1:7890")
|
|
||||||
req := client.R()
|
req := client.R()
|
||||||
req.SetHeader("Authorization", "Bearer "+g.accessToken)
|
req.SetHeader("Authorization", "Bearer "+g.accessToken)
|
||||||
if callback != nil {
|
if callback != nil {
|
||||||
|
|
@ -251,7 +249,6 @@ type googleTokenRes struct {
|
||||||
|
|
||||||
func RefreshGoogleToken(grantType string, tokenType string, varMap map[string]interface{}) (string, error) {
|
func RefreshGoogleToken(grantType string, tokenType string, varMap map[string]interface{}) (string, error) {
|
||||||
client := resty.New()
|
client := resty.New()
|
||||||
client.SetProxy("http://127.0.0.1:7890")
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"client_id": loadParamFromVars("client_id", varMap),
|
"client_id": loadParamFromVars("client_id", varMap),
|
||||||
"client_secret": loadParamFromVars("client_secret", varMap),
|
"client_secret": loadParamFromVars("client_secret", varMap),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue