Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add secrets to request headers #78

Closed
RandomFractals opened this issue Apr 20, 2021 · 14 comments
Closed

add secrets to request headers #78

RandomFractals opened this issue Apr 20, 2021 · 14 comments

Comments

@RandomFractals
Copy link
Contributor

some REST APIs typically use app or api key headers to validate requests.

Would be great to pass those required custom header values from vscode secrets, without adding them as plain text in rest books.

see how to use new Secrets API here: microsoft/vscode#112249 (comment)

@tanhakabir
Copy link
Owner

oh good point! Thanks for pointing me to the API 😊 I'll into this, this week!

@RandomFractals
Copy link
Contributor Author

great! simple example would be something along the lines of XYZ requires XYZ-API-KEY header

XYZ-API-KEY: <Key>

not sure how you'd want to demarcate this encrypted key in the header line of your notebook cell.

also, extensions can set those keys too, but maybe your output renderer can have a Secrets tab that allows us to set and reveal those keys used for HTTPS requests.

@tanhakabir
Copy link
Owner

@RandomFractals hey! added secrets and editing abilities with quick picks

recording (33)

@tanhakabir
Copy link
Owner

Renamed secrets to be accessible through $SECRETS

@RandomFractals
Copy link
Contributor Author

RandomFractals commented Apr 25, 2021

@tanhakabir this looks good! with this change, can we also access added secrets when constructing GET urls with query params? Some platforms require app/api keys to be passed that way for their data/service calls.

I'll check it out today. Thanks for this update!

@tanhakabir
Copy link
Owner

@RandomFractals yep! It's available now! I made the secrets available like variables so you can use them in query params, headers, and bodies 😊

@RandomFractals
Copy link
Contributor Author

RandomFractals commented Apr 25, 2021

worked like magic. I can't share my actual call screen pic, but here is an anonimized bit I just used for one of my rest endpoint tests:

https://api.<XYZ>.com/api/<serviceName>
    ?from=1475085940
    &to=1619085940
XYZ-API-KEY: $SECRETS.XYZ-API-KEY
XYZ-APPLICATION-KEY: $SECRETS.XYZ-APPLICATION-KEY
Content-Type: application/json

🙌

@dfinke
Copy link

dfinke commented May 17, 2021

I'm trying to authenticate to GitHub with my PAT.

Do I have the right syntax for the Authorization?

image

@tanhakabir
Copy link
Owner

Hm let me see there might be a bug for this case! Will have a fix out in the next 1-2 hours

@tanhakabir tanhakabir reopened this May 17, 2021
@RandomFractals
Copy link
Contributor Author

RandomFractals commented May 17, 2021

that would be nice. does that mean with that fix we can mock JWT for oauth too via $SECRETS vars? 🤔

I think #24 is potentially related if we can save and get tokens from secrets.

Those would need to be saved and automatically updated for refresh and bearer tokens.

see here for more info: https://www.oauth.com/oauth2-servers/access-tokens/

@RandomFractals
Copy link
Contributor Author

RandomFractals commented May 17, 2021

btw, good way to test OAuth would be using unfolded.ai data sdk that has the whole process nicely documented:

https://docs.unfolded.ai/data-sdk/authentication

my starter kit for unfolded maps is here if you'd like to explore their stack more: https://github.com/RandomFractals/unfolded-maps

they have ipywidget that does data queries, but would be nice to use their data rest end point straight from rest book if oauth 2 is supported.

@tanhakabir
Copy link
Owner

I didn't look into more complexity with OAuth but fixed the issue @dfinke had

@RandomFractals
Copy link
Contributor Author

that's fine. I should have added those comments on getting oauth tokens to work in #24.

@dfinke
Copy link

dfinke commented May 17, 2021

Thank you, works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants