1
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"sort"
|
||||
@@ -98,6 +99,7 @@ func (a *API) signParams(params map[string]interface{}) (sign string) {
|
||||
}
|
||||
|
||||
finalStr := strings.Join(strList, "&")
|
||||
globals.SugarLogger.Debugf("============finalStr: %s", finalStr)
|
||||
d := sha256.Sum256([]byte(finalStr))
|
||||
signature, _ := rsa.SignPKCS1v15(rand.Reader, a.privateKey, crypto.SHA256, d[:])
|
||||
sign = base64.StdEncoding.EncodeToString(signature)
|
||||
@@ -128,6 +130,7 @@ func (a *API) AccessAPI(method string, params, bizContent map[string]interface{}
|
||||
var request *http.Request
|
||||
params["timestamp"] = utils.GetCurTimeStr()
|
||||
params[signKey] = a.signParams(params)
|
||||
globals.SugarLogger.Debugf("======sginKey := %v", params[signKey])
|
||||
|
||||
fullURL := utils.GenerateGetURL(prodURL, "", params)
|
||||
if isPost {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package alipayapi
|
||||
|
||||
import "git.rosy.net.cn/baseapi/utils"
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
const (
|
||||
GrantTypeCode = "authorization_code"
|
||||
@@ -52,6 +55,8 @@ func (a *API) SystemAuthToken(grantType, code, refreshToken string) (tokenInfo *
|
||||
params["alipay_root_cert_sn"] = aliPayRootCertSN
|
||||
|
||||
retVal, err := a.AccessAPI("alipay.system.oauth.token", params, nil, false)
|
||||
globals.SugarLogger.Debugf("======retVal := %v", retVal)
|
||||
globals.SugarLogger.Debugf("======err := %v", err)
|
||||
if err == nil {
|
||||
err = utils.Map2StructByJson(retVal, &tokenInfo, false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user