baking-bad / pytezos

🐍 Python SDK for Tezos | Michelson VM in Python
https://pytezos.org
MIT License
111 stars 36 forks source link

Additional custom header when requesting a RPC node #339

Closed aboulay closed 1 year ago

aboulay commented 1 year ago

Hi everyone,

We are currently trying to join a commercial Tezos RPC node which are exposed through a proxy and we have seen they have a pretty cool functionality which permits to use a JWT with a header Authorization: Bearer <base64 encoded token> or a simple password with a header Authorization: Basic <base64 encoded token> to authenticate and connect to the node in addition of a unique url.

I have seen nothing in the documentation which permits to add a custom header to the request built by the pytezos library and I don't know if there is a possibility to do it. Have I missed something about it? If not, do you think it could be a useful feature for pytezos users?

Edit: For the JWT, the header is Authorization: Bearer instead of Authorization: Basic. This has be reported on the main message.

m-kus commented 1 year ago

Hey!

Once 3.7.4 is available on pypi, you can update and do the following:

from pytezos.rpc.node import RpcNode
from pytezos.rpc.shell import ShellQuery

pytezos = pytezos.using(shell=ShellQuery(RpcNode("https://rpc.tzkt.io/ghostnet", headers={"User-agent": "Hello"})))