|
|
@@ -0,0 +1,61 @@ |
|
|
|
package tik_tok |
|
|
|
|
|
|
|
import ( |
|
|
|
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" |
|
|
|
"github.com/tidwall/gjson" |
|
|
|
"time" |
|
|
|
) |
|
|
|
|
|
|
|
//第一次授权 |
|
|
|
func OpenFirstAuth(args map[string]string) map[string]string { |
|
|
|
params := map[string]string{"code": args["code"], "grant_type": args["grantType"]} |
|
|
|
send, err := OpenSend(args["appkey"], args["appSecret"], "access_token", params, args["acctoken"]) |
|
|
|
var data = map[string]string{} |
|
|
|
if err != nil { |
|
|
|
return data |
|
|
|
} |
|
|
|
endTime := time.Now().Unix() + gjson.Get(send, "data.expires_in").Int() |
|
|
|
refreshEndTime := time.Now().Unix() + gjson.Get(send, "data.refresh_expires_in").Int() |
|
|
|
data = map[string]string{ |
|
|
|
"tik_tok_acc_token": gjson.Get(send, "data.access_token").String(), |
|
|
|
"tik_tok_acc_token_time": zhios_third_party_utils.Int64ToStr(endTime), |
|
|
|
"tik_tok_acc_refresh_token_time": zhios_third_party_utils.Int64ToStr(refreshEndTime), |
|
|
|
"tik_tok_acc_refresh_token": gjson.Get(send, "data.refresh_token").String(), |
|
|
|
"tik_tok_open_id": gjson.Get(send, "data.open_id").String(), |
|
|
|
"tik_tok_scope": gjson.Get(send, "data.scope").String(), |
|
|
|
} |
|
|
|
return data |
|
|
|
} |
|
|
|
func OpenRefreshAccessAuth(args map[string]string) map[string]string { |
|
|
|
params := map[string]string{"refresh_token": args["refresh_token"], "grant_type": "refresh_token"} |
|
|
|
send, err := OpenSend(args["appkey"], args["appSecret"], "refresh_token", params, args["acctoken"]) |
|
|
|
var data = map[string]string{} |
|
|
|
if err != nil { |
|
|
|
return data |
|
|
|
} |
|
|
|
endTime := time.Now().Unix() + gjson.Get(send, "data.expires_in").Int() |
|
|
|
refreshEndTime := time.Now().Unix() + gjson.Get(send, "data.refresh_expires_in").Int() |
|
|
|
data = map[string]string{ |
|
|
|
"tik_tok_acc_token": gjson.Get(send, "data.access_token").String(), |
|
|
|
"tik_tok_acc_token_time": zhios_third_party_utils.Int64ToStr(endTime), |
|
|
|
"tik_tok_acc_refresh_token_time": zhios_third_party_utils.Int64ToStr(refreshEndTime), |
|
|
|
"tik_tok_acc_refresh_token": gjson.Get(send, "data.refresh_token").String(), |
|
|
|
"tik_tok_open_id": gjson.Get(send, "data.open_id").String(), |
|
|
|
"tik_tok_scope": gjson.Get(send, "data.scope").String(), |
|
|
|
} |
|
|
|
return data |
|
|
|
} |
|
|
|
func OpenRefreshAuth(args map[string]string) map[string]string { |
|
|
|
params := map[string]string{"refresh_token": args["refresh_token"]} |
|
|
|
send, err := OpenSend(args["appkey"], args["appSecret"], "renew_refresh_token", params, args["acctoken"]) |
|
|
|
var data = map[string]string{} |
|
|
|
if err != nil { |
|
|
|
return data |
|
|
|
} |
|
|
|
endTime := time.Now().Unix() + gjson.Get(send, "data.expires_in").Int() |
|
|
|
data = map[string]string{ |
|
|
|
"tik_tok_acc_token": gjson.Get(send, "data.refresh_token").String(), |
|
|
|
"tik_tok_acc_token_time": zhios_third_party_utils.Int64ToStr(endTime), |
|
|
|
} |
|
|
|
return data |
|
|
|
} |