rstudio / pins-python

https://rstudio.github.io/pins-python/
MIT License
49 stars 12 forks source link

API-Key Header in board_rsconnect #176

Closed ni2scmn closed 1 year ago

ni2scmn commented 1 year ago

Hi,

it seems that there is a casing error in the function _get_headers in the class RsConnectApi.

The api_keys gets formatted as d_key = {"Authorization": f"key {api_key}"} if api_key is not None else {} while in the docs it is referered as 'Key' link

This leads to an error on my side

Source of error

machow commented 1 year ago

Thanks for your report. Can you post the traceback for your error? pins runs tests against rsconnect using an API Key, so I'm curious to dig deeper into what could be going on...

ni2scmn commented 1 year ago

Actually the request is simply stuck. I am not that deep into it to give you further details but in case no authorization is given to our connect server, you are redirected to an Microsoft page to identify you by OpenID. And this is the case if the word 'key' in the header is in lower case. 'Key' is accepted correctly and does no forwarding to an authorization page.

machow commented 1 year ago

Thanks for the extra details -- could you give some code or extra context on how you are checking that "Key" is accepted? Are you using python with requests or something similar?

@sellorm, I seem to recall you had mentioned issues with pins authentication before. Any chance you've seen this situation before?!

machow commented 1 year ago

I'm noticing that the rsconnect R package uses "Key", so changing here to use "Key" rather than "key" seems like a pretty straightforward switch!

https://github.com/rstudio/rsconnect/blob/e42166e4d0d39ead451165c30a0dd847dc11e639/R/http.R#L358

ni2scmn commented 1 year ago

I actually just replaced the word in the source of the pins package and that fixed the error on my side.

machow commented 1 year ago

This should be released now as v0.7.3