Skip to content

GO client does not return headers from http response #60

@arihant30

Description

@arihant30

The Login API is supposed to sign-in a User and return a "Set-Cookie" header that contains the refresh token and access token, but the client does not read the headers from the response, nor does it return them.
A workaround is to call the login API yourself instead of using the go-client and reading the headers from the response.

func (rc *restClient) Do() error {
	req, err := http.NewRequest("POST", rc.Uri.String(), rc.Body)
	if err != nil {
		return err
	}
	for key, val := range rc.Headers {
		req.Header.Set(key, val)
	}
	resp, err := rc.HTTPClient.Do(req)
	if err != nil {
		return err
	}
// Reading the headers from the response
	key := resp.Header.Values("Set-Cookie")
	if key != nil {
		rc.Cookie = key
	}
	defer resp.Body.Close()
	if resp.StatusCode < 200 || resp.StatusCode > 299 {
		return errors.BaseBadRequest
	} else {
		rc.ErrorRef = nil
		if _, ok := rc.ResponseRef.(*BaseHTTPResponse); !ok {
			err = json.NewDecoder(resp.Body).Decode(rc.ResponseRef)
		}
	}
	return err
}

This is a workaround that I have used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions