diff --git a/lib/authentication/authentication_client.go b/lib/authentication/authentication_client.go index b3ae82e..8115162 100644 --- a/lib/authentication/authentication_client.go +++ b/lib/authentication/authentication_client.go @@ -420,7 +420,7 @@ func (c *Client) SendHttpRequestManage(url string, method string, query string, req.Header.Add("x-authing-userpool-id", ""+c.UserPoolId) req.Header.Add("x-authing-request-from", constant.SdkType) req.Header.Add("x-authing-sdk-version", constant.SdkVersion) - req.Header.Add("x-authing-app-id", ""+constant.AppId) + req.Header.Add("x-authing-app-id", ""+c.AppId) res, err := c.HttpClient.Do(req) if err != nil { @@ -510,11 +510,10 @@ func (c *Client) SendHttpRestRequest(url string, method string, token *string, v token = &selfToken } req.Header.Add("Authorization", "Bearer "+*token) - req.Header.Add("x-authing-userpool-id", ""+c.UserPoolId) req.Header.Add("x-authing-request-from", constant.SdkType) req.Header.Add("x-authing-sdk-version", constant.SdkVersion) - req.Header.Add("x-authing-app-id", ""+constant.AppId) + req.Header.Add("x-authing-app-id", ""+c.AppId) res, err := c.HttpClient.Do(req) if err != nil { return nil, err @@ -551,7 +550,7 @@ func (c *Client) SendHttpRestRequestNotToken(url string, method string, variable req.Header.Add("x-authing-userpool-id", ""+c.UserPoolId) req.Header.Add("x-authing-request-from", constant.SdkType) req.Header.Add("x-authing-sdk-version", constant.SdkVersion) - req.Header.Add("x-authing-app-id", ""+constant.AppId) + req.Header.Add("x-authing-app-id", ""+c.AppId) res, err := c.HttpClient.Do(req) if err != nil { return nil, err @@ -1049,7 +1048,7 @@ func (c *Client) SendHttpRequestCustomTokenManage(url string, method string, tok req.Header.Add("x-authing-userpool-id", ""+c.UserPoolId) req.Header.Add("x-authing-request-from", constant.SdkType) req.Header.Add("x-authing-sdk-version", constant.SdkVersion) - req.Header.Add("x-authing-app-id", ""+constant.AppId) + req.Header.Add("x-authing-app-id", ""+c.AppId) res, err := c.HttpClient.Do(req) if err != nil { @@ -1222,7 +1221,11 @@ func (c *Client) Logout() (*model.CommonMessageAndCode, error) { func (c *Client) LogoutByToken(token string) (*model.CommonMessageAndCode, error) { url := fmt.Sprintf("%s/api/v2/logout?app_id=%s", c.Host, c.AppId) - b, err := c.SendHttpRestRequest(url, http.MethodGet, &token, nil) + variables := make(map[string]interface{}) + + variables["withCredentials"] = true + fmt.Println(url) + b, err := c.SendHttpRestRequest(url, http.MethodGet, &token, variables) if err != nil { return nil, err } diff --git a/lib/authentication/authentication_client_test.go b/lib/authentication/authentication_client_test.go index 4f4fd42..e6a1518 100644 --- a/lib/authentication/authentication_client_test.go +++ b/lib/authentication/authentication_client_test.go @@ -18,6 +18,22 @@ const ( UserPool = "" ) +func TestClient_LogoutByToken(t *testing.T) { + authenticationClient := NewClient(AppId, Secret, "https://hfggf.authing.cn") + authenticationClient.UserPoolId = UserPool + model := model.LoginByEmailInput{} + model.Email = "zy@pm.com" + model.Password = "zy" + user, err := authenticationClient.LoginByEmail(model) + if err != nil { + fmt.Println(err) + } + fmt.Println(*user.Token) + res, err := authenticationClient.LogoutByToken(*(user.Token)) + fmt.Println(res, err) + fmt.Println(authenticationClient.CheckLoginStatus(*(user.Token))) +} + func TestClient_BuildAuthorizeUrlByOidc(t *testing.T) { authenticationClient := NewClient(AppId, Secret) authenticationClient.Protocol = constant.OIDC