`_resolve_features` ignores the token
MEMBER
Hi ! Your HF_ENDPOINT seems wrong because of the extra "/"
```diff
- os.environ["HF_ENDPOINT"] = "https://hub-ci.huggingface.co/"
+ os.environ["HF_ENDPOINT"] = "https://hub-ci.huggingface.co"
```

can you try again without the extra "/" ?
2022-08-24T14:38:21Z
https://github.com/huggingface/datasets/issues/4875#issuecomment-1225817392
https://api.github.com/repos/huggingface/datasets/issues/4875
IC_kwDODunzps5JEH0w
https://api.github.com/repos/huggingface/datasets/issues/comments/1225817392/reactions
2022-08-24T14:38:21Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1225817392
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
COLLABORATOR
Oh, yes, sorry, but it's not the issue.

In my code, I set `HF_ENDPOINT=https://hub-ci.huggingface.co`. I added `os.environ["HF_ENDPOINT"] = "https://hub-ci.huggingface.co/"` afterward just to indicate that we had to have this env var and made a mistake there
2022-08-24T14:41:21Z
https://github.com/huggingface/datasets/issues/4875#issuecomment-1225821191
https://api.github.com/repos/huggingface/datasets/issues/4875
IC_kwDODunzps5JEIwH
https://api.github.com/repos/huggingface/datasets/issues/comments/1225821191/reactions
2022-08-24T14:41:21Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1225821191
https://avatars.githubusercontent.com/u/1676121?v=4
https://api.github.com/users/severo/events{/privacy}
https://api.github.com/users/severo/followers
https://api.github.com/users/severo/following{/other_user}
https://api.github.com/users/severo/gists{/gist_id}
https://github.com/severo
severo
MDQ6VXNlcjE2NzYxMjE=
https://api.github.com/users/severo/orgs
https://api.github.com/users/severo/received_events
https://api.github.com/users/severo/repos
https://api.github.com/users/severo/starred{/owner}{/repo}
https://api.github.com/users/severo/subscriptions
User
https://api.github.com/users/severo
public
MEMBER
I can't reproduce on my side. I tried using a private dataset repo with a CSV file on hub-ci

What's your version of `huggingface_hub` ?
2022-08-24T15:07:50Z
https://github.com/huggingface/datasets/issues/4875#issuecomment-1225854832
https://api.github.com/repos/huggingface/datasets/issues/4875
IC_kwDODunzps5JEQ9w
https://api.github.com/repos/huggingface/datasets/issues/comments/1225854832/reactions
2022-08-24T15:07:50Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1225854832
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
COLLABORATOR
I can't reproduce either... Not sure what has occurred, very sorry to have made you lost your time on that 
2022-08-24T16:33:30Z
https://github.com/huggingface/datasets/issues/4875#issuecomment-1225964777
https://api.github.com/repos/huggingface/datasets/issues/4875
IC_kwDODunzps5JErzp
https://api.github.com/repos/huggingface/datasets/issues/comments/1225964777/reactions
2022-08-24T16:33:30Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1225964777
https://avatars.githubusercontent.com/u/1676121?v=4
https://api.github.com/users/severo/events{/privacy}
https://api.github.com/users/severo/followers
https://api.github.com/users/severo/following{/other_user}
https://api.github.com/users/severo/gists{/gist_id}
https://github.com/severo
severo
MDQ6VXNlcjE2NzYxMjE=
https://api.github.com/users/severo/orgs
https://api.github.com/users/severo/received_events
https://api.github.com/users/severo/repos
https://api.github.com/users/severo/starred{/owner}{/repo}
https://api.github.com/users/severo/subscriptions
User
https://api.github.com/users/severo
public
COLLABORATOR
I got something similar in https://github.com/huggingface/datasets-server/pull/608. Look how changing the order of the tests (https://github.com/huggingface/datasets-server/pull/608/commits/2c50fe833323de3dfdc76c5cd68639279e0887f8) change the result, which means that something has a side-effect:
- https://github.com/huggingface/datasets-server/actions/runs/3264636253/jobs/5365612918 works
- https://github.com/huggingface/datasets-server/actions/runs/3264651839/jobs/5365654924 does not work

I still couldn't reproduce it with a simpler script... 
2022-10-17T11:59:55Z
https://github.com/huggingface/datasets/issues/4875#issuecomment-1280744233
https://api.github.com/repos/huggingface/datasets/issues/4875
IC_kwDODunzps5MVpsp
https://api.github.com/repos/huggingface/datasets/issues/comments/1280744233/reactions
2022-10-17T11:59:55Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1280744233
https://avatars.githubusercontent.com/u/1676121?v=4
https://api.github.com/users/severo/events{/privacy}
https://api.github.com/users/severo/followers
https://api.github.com/users/severo/following{/other_user}
https://api.github.com/users/severo/gists{/gist_id}
https://github.com/severo
severo
MDQ6VXNlcjE2NzYxMjE=
https://api.github.com/users/severo/orgs
https://api.github.com/users/severo/received_events
https://api.github.com/users/severo/repos
https://api.github.com/users/severo/starred{/owner}{/repo}
https://api.github.com/users/severo/subscriptions
User
https://api.github.com/users/severo
public
MEMBER
The issue happens because `extend_module_for_streaming` can't be used several times on packaged builders like `csv` to apply a new auth token. Indeed `extend_module_for_streaming` only applies authentication once, and on subsequent calls does nothing:

https://github.com/huggingface/datasets/blob/07b7c38d9e9c72c74b02524c432ca64d0d3738f4/src/datasets/streaming.py#L62-L64

This behavior exists because the authenticatoin wrapper only supports one token. This is an issue for packaged builders which can be used to load several datasets, so it may require several tokens.

This can be fixed by storing a dict `token_per_repo_id` instead of `use_auth_token` in the authentication wrapper, and by making it possible to update the authentication wrapper with a new token
2022-10-17T12:58:37Z
https://github.com/huggingface/datasets/issues/4875#issuecomment-1280821172
https://api.github.com/repos/huggingface/datasets/issues/4875
IC_kwDODunzps5MV8e0
https://api.github.com/repos/huggingface/datasets/issues/comments/1280821172/reactions
2022-10-17T12:58:37Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1280821172
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
COLLABORATOR
I fixed the datasets-server CI with: https://github.com/huggingface/datasets-server/pull/608

See https://github.com/huggingface/datasets-server/actions/runs/3265359326/jobs/5367445018

Thanks for the help @lhoestq !
2022-10-17T13:08:16Z
https://github.com/huggingface/datasets/issues/4875#issuecomment-1280833990
https://api.github.com/repos/huggingface/datasets/issues/4875
IC_kwDODunzps5MV_nG
https://api.github.com/repos/huggingface/datasets/issues/comments/1280833990/reactions
2022-10-17T13:08:16Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1280833990
https://avatars.githubusercontent.com/u/1676121?v=4
https://api.github.com/users/severo/events{/privacy}
https://api.github.com/users/severo/followers
https://api.github.com/users/severo/following{/other_user}
https://api.github.com/users/severo/gists{/gist_id}
https://github.com/severo
severo
MDQ6VXNlcjE2NzYxMjE=
https://api.github.com/users/severo/orgs
https://api.github.com/users/severo/received_events
https://api.github.com/users/severo/repos
https://api.github.com/users/severo/starred{/owner}{/repo}
https://api.github.com/users/severo/subscriptions
User
https://api.github.com/users/severo
public
COLLABORATOR
> This can be fixed by storing a dict token_per_repo_id instead of use_auth_token in the authentication wrapper, and by making it possible to update the authentication wrapper with a new token

If I call the module on the same repo twice: first with authentication, then without authentication, would the second call use authentication anyway? It sounds like a bug: the argument passed to the function would be silently ignored.
2022-10-17T13:13:25Z
https://github.com/huggingface/datasets/issues/4875#issuecomment-1280840640
https://api.github.com/repos/huggingface/datasets/issues/4875
IC_kwDODunzps5MWBPA
https://api.github.com/repos/huggingface/datasets/issues/comments/1280840640/reactions
2022-10-17T13:13:47Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1280840640
https://avatars.githubusercontent.com/u/1676121?v=4
https://api.github.com/users/severo/events{/privacy}
https://api.github.com/users/severo/followers
https://api.github.com/users/severo/following{/other_user}
https://api.github.com/users/severo/gists{/gist_id}
https://github.com/severo
severo
MDQ6VXNlcjE2NzYxMjE=
https://api.github.com/users/severo/orgs
https://api.github.com/users/severo/received_events
https://api.github.com/users/severo/repos
https://api.github.com/users/severo/starred{/owner}{/repo}
https://api.github.com/users/severo/subscriptions
User
https://api.github.com/users/severo
public
MEMBER
Yes exactly, this is a known bug
2022-10-17T13:31:21Z
https://github.com/huggingface/datasets/issues/4875#issuecomment-1280866283
https://api.github.com/repos/huggingface/datasets/issues/4875
IC_kwDODunzps5MWHfr
https://api.github.com/repos/huggingface/datasets/issues/comments/1280866283/reactions
2022-10-17T13:31:21Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1280866283
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
COLLABORATOR
And do you think this bug could be solved as well when fixing this issue?
2022-10-17T13:38:44Z
https://github.com/huggingface/datasets/issues/4875#issuecomment-1280876827
https://api.github.com/repos/huggingface/datasets/issues/4875
IC_kwDODunzps5MWKEb
https://api.github.com/repos/huggingface/datasets/issues/comments/1280876827/reactions
2022-10-17T13:38:44Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1280876827
https://avatars.githubusercontent.com/u/1676121?v=4
https://api.github.com/users/severo/events{/privacy}
https://api.github.com/users/severo/followers
https://api.github.com/users/severo/following{/other_user}
https://api.github.com/users/severo/gists{/gist_id}
https://github.com/severo
severo
MDQ6VXNlcjE2NzYxMjE=
https://api.github.com/users/severo/orgs
https://api.github.com/users/severo/received_events
https://api.github.com/users/severo/repos
https://api.github.com/users/severo/starred{/owner}{/repo}
https://api.github.com/users/severo/subscriptions
User
https://api.github.com/users/severo
public
MEMBER
yes definitely !
2022-10-17T13:45:47Z
https://github.com/huggingface/datasets/issues/4875#issuecomment-1280887498
https://api.github.com/repos/huggingface/datasets/issues/4875
IC_kwDODunzps5MWMrK
https://api.github.com/repos/huggingface/datasets/issues/comments/1280887498/reactions
2022-10-17T13:45:47Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1280887498
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
## Describe the bug

When calling [`_resolve_features()`](https://github.com/huggingface/datasets/blob/54b532a8a2f5353fdb0207578162153f7b2da2ec/src/datasets/iterable_dataset.py#L1255) on a gated dataset, ie. a dataset which requires a token to be loaded, the token seems to be ignored even if it has been provided to `load_dataset` before.

## Steps to reproduce the bug

```python
import os

os.environ["HF_ENDPOINT"] = "https://hub-ci.huggingface.co/"
hf_token = "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"

from datasets import load_dataset

# public
dataset_name = "__DUMMY_DATASETS_SERVER_USER__/repo_csv_data-16612654226756"
config_name = "__DUMMY_DATASETS_SERVER_USER__--repo_csv_data-16612654226756"
split_name = "train"

iterable_dataset = load_dataset(
    dataset_name,
    name=config_name,
    split=split_name,
    streaming=True,
    use_auth_token=hf_token,
)
iterable_dataset = iterable_dataset._resolve_features()
print(iterable_dataset.features)

# gated
dataset_name = "__DUMMY_DATASETS_SERVER_USER__/repo_csv_data-16612654317644"
config_name = "__DUMMY_DATASETS_SERVER_USER__--repo_csv_data-16612654317644"
split_name = "train"


iterable_dataset = load_dataset(
    dataset_name,
    name=config_name,
    split=split_name,
    streaming=True,
    use_auth_token=hf_token,
)
try:
    iterable_dataset = iterable_dataset._resolve_features()
except FileNotFoundError as e:
    print("FAILS")
```

## Expected results

I expect to have the same result on a public dataset and on a gated (or private) dataset, if the token has been provided.

## Actual results

An exception is thrown on gated datasets.

## Environment info

- `datasets` version: 2.4.0
- Platform: Linux-5.15.0-1017-aws-x86_64-with-glibc2.35
- Python version: 3.9.6
- PyArrow version: 7.0.0
- Pandas version: 1.4.2