Skip to content

feat: check if running on Connect and grab user session token within get_oauth_credentials() #366

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

Closed
dethmasque opened this issue Jan 29, 2025 · 2 comments
Assignees

Comments

@dethmasque
Copy link

When using connectapi to exchange the user session token for an OAuth access token the environment check and user session token acquisition occur outside of the connectapi package, ex:

  # check if running on Posit Connect
  if (Sys.getenv("RSTUDIO_PRODUCT") == "CONNECT") {
    # initialize Connect API client
    client <- connect()
    # read the user-session-token header
    user_session_token <- session$request$HTTP_POSIT_CONNECT_USER_SESSION_TOKEN
    # grab the OAuth Integration access token using the session token
    credentials <- get_oauth_credentials(client, user_session_token)
    token <- credentials$access_token

We should build this into connectapi.

@dethmasque dethmasque self-assigned this Jan 29, 2025
@tdstein
Copy link
Collaborator

tdstein commented Mar 11, 2025

When running applications in Connect which use the connectapi package, the behavior should be what our users expect to happen. Which is the application uses the viewers credentials by default, instead of the content owners (e.g., CONNECT_API_KEY) credentials. This will break deployment by default, if the content owner has not setup the oauth integration. Therefore, the should be directed towards how to do that when it occurs.

When running locally, the CONNECT_API_KEY should be used.

@toph-allen toph-allen assigned toph-allen and unassigned dethmasque Mar 18, 2025
@toph-allen
Copy link
Collaborator

Closing this as a duplicate of #384 — that's where more of my thoughts are. The conditional check described above is necessary, but this is a problem with documentation, I think.

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