rstudio / pins-r

Pin, discover, and share resources
https://pins.rstudio.com
Other
316 stars 62 forks source link

! Posit Connect API failed [401] #708

Closed tsharaf closed 1 year ago

tsharaf commented 1 year ago

I have a RMarkdown file that runs on schedule on Posit Connect every hour. The job writes a Pin to Posit with new dataframe.

I am getting Posit Connect API failed [401] few of the 24 times this task is supposed to run and when I check the log I get the following:

Error in rsc_check_status(): 02/13 21:23:29.270 (GMT) ! Posit Connect API failed [401] 02/13 21:23:29.309 (GMT) • We couldn't log you in with the provided credentials. Please ask your administrator for assistance. 02/13 21:23:29.309 (GMT) Backtrace: 02/13 21:23:29.309 (GMT)

  1. pins::pin_write(...) 02/13 21:23:29.309 (GMT)
  2. pins:::pin_store.pins_board_connect(...) 02/13 21:23:29.309 (GMT)
  3. pins:::rsc_GET(board, rsc_v1("tasks", task_id), list(wait = 1)) 02/13 21:23:29.309 (GMT)
  4. pins:::rsc_check_status(req)

I am unable to figure out why the same file runs fines with same credentials and other it gives an error. I am using Pins 1.1.0 and connecting to Posit Connect using board_connect with my account and API key.

The error takes place when using pin_write

juliasilge commented 1 year ago

That sounds so frustrating @tsharaf! 😫 Since the problem is intermittent like you described, it's not going to be related to the open source code in pins but rather something in how Connect is working in your specific instance. I suggest that you open a support ticket outlining your intermittent problems with authenticating to Connect.

Good luck! 💪

juliasilge commented 1 year ago

Let us know if you have any further problems!

dareneiri commented 1 year ago

@tsharaf Just wanted to let you know I have a very similar issue (same error related to authentication), but haven't been able to properly debug it. Also using Connect to store and retrieve pins, and it happens seemingly random.

tsharaf commented 1 year ago

@dareneiri I have contacted Posit Connect and they recommend to add the following line in my document:

httr::set_config(config(ssl_verifypeer = FALSE, ssl_verifyhost = FALSE))

and so far the document is running without any issues

github-actions[bot] commented 1 year ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.