Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TokenParser Function #105

Closed
kristinapathak opened this issue May 27, 2021 · 0 comments
Closed

Update TokenParser Function #105

kristinapathak opened this issue May 27, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@kristinapathak
Copy link
Contributor

bascule/acquire/bearer.go

Lines 136 to 144 in c011b12

respBody, errRead := ioutil.ReadAll(resp.Body)
if errRead != nil {
return "", fmt.Errorf("error reading HTTP response body: %v", errRead)
}
token, err := acquirer.options.GetToken(respBody)
if err != nil {
return "", fmt.Errorf("error parsing bearer token from http response body: %v", err)
}

Currently, we don't check the response's Content-Type header before reading the body and passing it to the TokenParser. It would be nice to provide this information to the TokenParser, either as a string parameter or by passing the http.Request and allowing the TokenParser to do its own validation and parsing from there. Either option allows us to give up on parsing something if its not in the form we expect, and allows for more flexible parsing - a TokenParser could parse differently depending on the Content-Type provided.

Passing the full response would make it the TokenParser's responsibility to read and close the response body. Passing the Content-Type as a string allows TokenParsers to have no dependency on the http package.

@kristinapathak kristinapathak added the enhancement New feature or request label May 27, 2021
@johnabass johnabass closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants