How to use gated models?

I had the same issues when I tried the Llama-2 model with a token passed through code. I gave up after while using cli.
But what I see from your error:
**

“Your request to access model meta-llama/Llama-2-7b-hf is awaiting a review from the repo authors.”

**
I have an assumption. I suspect some auth response caching issues or - less likely - some extreme response caching expiration time values. As you said you could login via notebook (and access the repo, I assume?), the caching seems to be client based. While I had issues with token auth too, now it works for with token (tried from secondary environment).