soroban-cli
soroban-cli copied to clipboard
CLI should support rpc providers which require an API key
What problem does your feature solve?
Close to 50% of RPC providers require developers to pass the API key in the authorization header. The CLI only enables passing a --rpc-url, not an API key
What would you like to see?
Be able to optional pass the RPC API Key when the RPC provider requires such
The ecosystem RPC providers list is here: https://developers.stellar.org/docs/data/rpc/rpc-providers. We cannot use blockdaemon for example.
+1.
Can we do some research on each provider and post back here with the format of their header to make sure there's some uniformity?
If there's not uniformity then we might need to rethink this to be a more generic param such as --rpc-header that accepts a full header such as --rpc-header 'Authorization: Bearer abc123'.
If there is uniformity, we can add it with param --rpc-api-key abc123.
And add an env var to accompany the param such as STELLAR_RPC_API_KEY, or similar for the header.
API Key format for Obsrvr
"Authorization: Api-Key 4rRrRTzZ.QDzg6MlgbNd2GUAIQoseyRRRRR0459yy"
Here's a spreadsheet with the research on what each RPC provider is expecting regarding API keys: https://docs.google.com/spreadsheets/d/125K7a0sb2qm6uq-2qo8JhtNT5WXOTDRyylsL7UaLyv0/.
To summarize, it seems like we have three different scenarios we need to account for to make sure all of the providers on this page](https://developers.stellar.org/docs/data/rpc/rpc-providers) are supported:
- The provider is expecting the api key in the url
- The provider is expecting a bearer token in the auth header (sometimes this bearer token is the API key directly, sometimes it is a jwt)
- The provider is expecting the api key in an "api-key" header
I think that we can handle those three scenarios with the suggestion that Leigh made above about adding an optional --rpc-header arg.
- for providers that expect the API key in the URL, users can use the existing
--rpc-urlarg
stellar contract deploy ... \
--rpc-url https://mainnet.stellar.validationcloud.io/v1/<API_KEY> \
--network-passphrase 'Public Global Stellar Network ; September 2015'
- for auth headers, users can use the new
--rpc-headerarg
stellar contract deploy ... \
--rpc-url 'https://svc.blockdaemon.com/stellar/mainnet/native/soroban-rpc' \
--rpc-header 'Authorization: Bearer <API_KEY>' \
--network-passphrase Public Global Stellar Network ; September 2015
- for api-key headers, users can use the new
--rpc-headerarg
stellar contract deploy ... --rpc-url 'https://soroban-mainnet.nownodes.io' \
--rpc-header 'api-key: <API_KEY>' \
--network-passphrase 'Public Global Stellar Network ; September 2015'
Thank you @elizabethengelman 🙏
cc @quietbits
I encountered this issue while using the Blockdaemon API. If the related work hasn't started yet, I would be happy to submit a PR.
@overcat Thanks for offering! We have a PR that's already in the works by @elizabethengelman