Comments (4)
Seems somewhat related to r-lib/httr#626, but in your example the hostname is the same. ... Oh but the protocol is different.
Anyway, I think setting unrestrict_auth
will solve your problem:
library(httr2)
request("http://httpbin.org/redirect-to?url=https://httpbin.org/bearer") |>
req_auth_bearer_token("TOKEN") |>
req_options(unrestricted_auth = 1) |>
req_perform(verbosity = 1)
from httr2.
It sorted out my problem. Thank you very much!
Would you consider setting this behaviour as the default in the future? It's the default for most HTTP clients.
from httr2.
I do not believe it is the default because it is security risk. I'd need a strong reason to justify overriding this:
By default, libcurl only sends credentials and Authentication headers to the initial hostname as given in the original URL, to avoid leaking username + password to other sites.
from httr2.
I see your point. I meant to refer to the other popular libraries. For instance, in Python:
>>> import requests
>>> requests.get(
... "http://httpbin.org/redirect-to?url=https://httpbin.org/bearer",
... headers={"Authorization": "Bearer TOKEN"},
... ).json()
{'authenticated': True, 'token': 'TOKEN'}
>>> import httpx
>>> httpx.get(
... "http://httpbin.org/redirect-to?url=https://httpbin.org/bearer",
... headers={"Authorization": "Bearer TOKEN"},
... follow_redirects=True,
... ).json()
{'authenticated': True, 'token': 'TOKEN'}
But I appreciate the security concerns. Thanks again!
from httr2.
Related Issues (20)
- Self-signed certificates HOT 1
- netrc-based authentication HOT 2
- mocking iterative requests HOT 1
- `req_body_json()` should set `Content-Type: application/json` header HOT 1
- Failure to download 0 byte file, in parallel: resp_has_body(x)) {: missing value where TRUE/FALSE needed HOT 3
- Cannot capture 4xx response bodies with req_perform_stream HOT 6
- osmdata producing error due to httr2 HOT 1
- Add support for server-sent events
- url_build() doesn't validate argument
- Suggestion: Pass through auth_url from oauth_client$auth_params to oauth_flow/req_oauth HOT 1
- I don't understand req_auth_basic's behavior HOT 1
- Make `req_cache(debug = TRUE)` settable from an option
- Cannot upload more than 128 files using req_perform_parallel HOT 3
- Example wanted: Logging in to legacy API without OAuth 2.0 support and parsing token to oauth_token HOT 5
- `req_oauth_password` prompts password-input continuously, but existing valid token are used HOT 2
- `curl_translate()` bugs
- feature request: `req_perform_promise()` HOT 1
- Try S7
- Release httr2 1.0.2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from httr2.