-
Notifications
You must be signed in to change notification settings - Fork 61
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
Make redirect_uri the primary interface #294
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me.
Co-authored-by: Aaron Jacobs <[email protected]>
#Conflicts: # NEWS.md # R/oauth-flow-auth-code.R # tests/testthat/test-oauth-flow-auth-code.R
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is already merged and I have not actually run this code. But I made a few comments in case it's helpful.
#' @param host_ip IP address for the temporary webserver used to capture the | ||
#' authorization code. | ||
#' @param type Either `desktop` or `web`. Use desktop when running on the | ||
#' desktop in an environment where you can redirect the user to `localhost`. | ||
#' Use `web` when running in a hosted web environment. | ||
#' @param port Port to bind the temporary webserver to. Used only when | ||
#' `redirect_uri` is `"http(s)://localhost"`. By default, this uses a random | ||
#' port. You may need to set it to a fixed port if the API requires that the | ||
#' `redirect_uri` specified in the client exactly matches the `redirect_uri` | ||
#' generated by this function. | ||
#' @param port Port to bind the temporary webserver to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the explicit docs for host_ip
and port
go away, since they are lumped in with the host_name
as deprecated in favor of redirect_uri
?
#' | ||
#' Alternatively, you can provide a URL to a website that uses javascript to | ||
#' give the user a code to copy and paste back into the R session (see | ||
#' <https://www.tidyverse.org/google-callback/>, for an example). This is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW gargle includes the source for a similar page (but minus the tidyverse branding), in case you want to do the same or point at that one:
https://github.com/r-lib/gargle/blob/main/inst/pseudo-oob/google-callback/index.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't traced through the httr2 code enough yet to know if this is already here: But the gargle example doesn't just emit the naked auth code. It checks for a state
and then packages/encodes the state
and code
.
Which then gets decoded and checked:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I added support for that in the original PR. It should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok. I was just focusing on the specific diffs in front of my 👀
lifecycle::deprecate_warn("0.3.0", "oauth_flow_auth_code(host_ip)") | ||
} | ||
|
||
localhost <- parsed$hostname == "localhost" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like you might one day have to ponder what happens if someone provides urn:ietf:wg:oauth:2.0:oob
as redirect_uri
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah and that seems like it will be a relatively straighforward change to make.
Fixes #149