mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-02-02 21:27:15 +08:00
refactor create session
This commit is contained in:
parent
8d2c40f1ce
commit
23fe54ce0b
@ -169,10 +169,7 @@ func RefreshTokenInNeed(activeUser *config.PanUser, deviceName string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create new signature
|
// create new signature
|
||||||
_, e := activeUser.PanClient().CreateSession(&aliyunpan.CreateSessionParam{
|
_, e := activeUser.PanClient().CreateSession(nil)
|
||||||
DeviceName: deviceName,
|
|
||||||
ModelName: "Windows网页版",
|
|
||||||
})
|
|
||||||
if e != nil {
|
if e != nil {
|
||||||
logger.Verboseln("call CreateSession error in RefreshTokenInNeed: " + e.Error())
|
logger.Verboseln("call CreateSession error in RefreshTokenInNeed: " + e.Error())
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,10 @@ doLoginAct:
|
|||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
PublicKey: "",
|
PublicKey: "",
|
||||||
}
|
}
|
||||||
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, appConfig)
|
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, appConfig, aliyunpan.SessionConfig{
|
||||||
|
DeviceName: deviceName,
|
||||||
|
ModelName: "Windows网页版",
|
||||||
|
})
|
||||||
u := &PanUser{
|
u := &PanUser{
|
||||||
WebToken: *webToken,
|
WebToken: *webToken,
|
||||||
panClient: panClient,
|
panClient: panClient,
|
||||||
@ -137,10 +140,7 @@ doLoginAct:
|
|||||||
// create session
|
// create session
|
||||||
appConfig.UserId = u.UserId
|
appConfig.UserId = u.UserId
|
||||||
panClient.UpdateAppConfig(appConfig)
|
panClient.UpdateAppConfig(appConfig)
|
||||||
r, e := panClient.CreateSession(&aliyunpan.CreateSessionParam{
|
r, e := panClient.CreateSession(nil)
|
||||||
DeviceName: deviceName,
|
|
||||||
ModelName: "Windows网页版",
|
|
||||||
})
|
|
||||||
if e != nil {
|
if e != nil {
|
||||||
logger.Verboseln("call CreateSession error in SetupUserByCookie: " + e.Error())
|
logger.Verboseln("call CreateSession error in SetupUserByCookie: " + e.Error())
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,16 @@ func TestFileActionMgrStart(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pan client
|
// pan client
|
||||||
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{})
|
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, aliyunpan.AppConfig{
|
||||||
|
AppId: "25dzX3vbYqktVxyX",
|
||||||
|
DeviceId: "E75459EXhOTkI5ZI6S3qDHA3",
|
||||||
|
UserId: "",
|
||||||
|
Nonce: 0,
|
||||||
|
PublicKey: "",
|
||||||
|
}, aliyunpan.SessionConfig{
|
||||||
|
DeviceName: "Chrome浏览器",
|
||||||
|
ModelName: "Windows网页版",
|
||||||
|
})
|
||||||
user, _ := panClient.GetUserInfo()
|
user, _ := panClient.GetUserInfo()
|
||||||
task := &SyncTask{
|
task := &SyncTask{
|
||||||
Id: "5b2d7c10-e927-4e72-8f9d-5abb3bb04814",
|
Id: "5b2d7c10-e927-4e72-8f9d-5abb3bb04814",
|
||||||
|
@ -25,7 +25,16 @@ func TestPanSyncDb(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pan client
|
// pan client
|
||||||
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{})
|
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, aliyunpan.AppConfig{
|
||||||
|
AppId: "25dzX3vbYqktVxyX",
|
||||||
|
DeviceId: "E75459EXhOTkI5ZI6S3qDHA3",
|
||||||
|
UserId: "",
|
||||||
|
Nonce: 0,
|
||||||
|
PublicKey: "",
|
||||||
|
}, aliyunpan.SessionConfig{
|
||||||
|
DeviceName: "Chrome浏览器",
|
||||||
|
ModelName: "Windows网页版",
|
||||||
|
})
|
||||||
|
|
||||||
// get user info
|
// get user info
|
||||||
ui, err := panClient.GetUserInfo()
|
ui, err := panClient.GetUserInfo()
|
||||||
|
@ -16,7 +16,16 @@ func TestStart(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pan client
|
// pan client
|
||||||
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{})
|
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, aliyunpan.AppConfig{
|
||||||
|
AppId: "25dzX3vbYqktVxyX",
|
||||||
|
DeviceId: "E75459EXhOTkI5ZI6S3qDHA3",
|
||||||
|
UserId: "",
|
||||||
|
Nonce: 0,
|
||||||
|
PublicKey: "",
|
||||||
|
}, aliyunpan.SessionConfig{
|
||||||
|
DeviceName: "Chrome浏览器",
|
||||||
|
ModelName: "Windows网页版",
|
||||||
|
})
|
||||||
user, _ := panClient.GetUserInfo()
|
user, _ := panClient.GetUserInfo()
|
||||||
|
|
||||||
manager := NewSyncTaskManager(
|
manager := NewSyncTaskManager(
|
||||||
@ -27,7 +36,7 @@ func TestStart(t *testing.T) {
|
|||||||
SyncOption{},
|
SyncOption{},
|
||||||
)
|
)
|
||||||
|
|
||||||
manager.Start(nil)
|
manager.Start(nil, StepSyncFile)
|
||||||
time.Sleep(30 * time.Minute)
|
time.Sleep(30 * time.Minute)
|
||||||
manager.Stop()
|
manager.Stop(StepSyncFile)
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,16 @@ func TestSyncTask(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pan client
|
// pan client
|
||||||
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{})
|
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, aliyunpan.AppConfig{
|
||||||
|
AppId: "25dzX3vbYqktVxyX",
|
||||||
|
DeviceId: "E75459EXhOTkI5ZI6S3qDHA3",
|
||||||
|
UserId: "",
|
||||||
|
Nonce: 0,
|
||||||
|
PublicKey: "",
|
||||||
|
}, aliyunpan.SessionConfig{
|
||||||
|
DeviceName: "Chrome浏览器",
|
||||||
|
ModelName: "Windows网页版",
|
||||||
|
})
|
||||||
user, _ := panClient.GetUserInfo()
|
user, _ := panClient.GetUserInfo()
|
||||||
task := SyncTask{
|
task := SyncTask{
|
||||||
Id: "5b2d7c10-e927-4e72-8f9d-5abb3bb04814",
|
Id: "5b2d7c10-e927-4e72-8f9d-5abb3bb04814",
|
||||||
|
Loading…
Reference in New Issue
Block a user