AUTH-1308: get jwt even when you are already logged in
This commit is contained in:
parent
611b284e20
commit
58daf6bfed
|
@ -83,21 +83,19 @@ func Run(transferURL *url.URL, resourceName, key, value, path string, shouldEncr
|
||||||
|
|
||||||
// BuildRequestURL creates a request suitable for a resource transfer.
|
// BuildRequestURL creates a request suitable for a resource transfer.
|
||||||
// it will return a constructed url based off the base url and query key/value provided.
|
// it will return a constructed url based off the base url and query key/value provided.
|
||||||
// follow will follow redirects.
|
// cli will build a url for cli transfer request.
|
||||||
func buildRequestURL(baseURL *url.URL, key, value string, follow bool) (string, error) {
|
func buildRequestURL(baseURL *url.URL, key, value string, cli bool) (string, error) {
|
||||||
q := baseURL.Query()
|
q := baseURL.Query()
|
||||||
q.Set(key, value)
|
q.Set(key, value)
|
||||||
baseURL.RawQuery = q.Encode()
|
baseURL.RawQuery = q.Encode()
|
||||||
if !follow {
|
if !cli {
|
||||||
return baseURL.String(), nil
|
return baseURL.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := http.Get(baseURL.String())
|
q.Set("redirect_url", baseURL.String()) // we add the token as a query param on both the redirect_url
|
||||||
if err != nil {
|
baseURL.RawQuery = q.Encode() // and this actual baseURL.
|
||||||
return "", err
|
baseURL.Path = "cdn-cgi/access/cli"
|
||||||
}
|
return baseURL.String(), nil
|
||||||
return response.Request.URL.String(), nil
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// transferRequest downloads the requested resource from the request URL
|
// transferRequest downloads the requested resource from the request URL
|
||||||
|
|
Loading…
Reference in New Issue