To modify the OAuth flow in httr2 to utilize idtoken instead of accesstoken, you need to make the following changes:
Update the authorization endpoint to include the OpenID Connect scope (openid
). This scope is required to request an id_token.
Set the response_type
parameter in the authorization request to code id_token
.
Request the id_token
parameter in the token request.
Verify the id_token
received from the token endpoint to ensure its authenticity.
Here is an example code snippet:
```{r} library(httr)
authurl <- "https://example.com/oauth2/authorize" tokenurl <- "https://example.com/oauth2/token" clientid <- "yourclientid" clientsecret <- "yourclientsecret" redirect_uri <- "https://localhost:1410"
myapp <- oauthapp("myapp", key = clientid, secret = clientsecret, redirecturi = redirect_uri)
authparams <- list(scope = "openid", responsetype = "code idtoken", redirecturi = redirect_uri, state = "myapp")
authurl <- oauth2.0authorizeurl(myapp, authurl, auth_params)
tokenparams <- list(granttype = "authorizationcode", redirecturi = redirecturi, code = "yourauthorizationcodereceivedfromtheredirecturi", id_token = "true")
token <- oauth2.0token(tokenurl, myapp, token_params)
jwt::jwtdecode(token$idtoken)
```
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-09-22 11:00:00 +0000
Seen: 15 times
Last updated: Mar 04 '23
What is OCPP Authorization and can you explain it in different words?
What are the steps to enable Keycloak to receive POST requests at an authorization endpoint?
Can you restate the following question: How do Web API, OWIN, and SignalR relate to Authorization?
How can I resolve the HttpClient authorization issue when using a Bearer Token?
How can set the Project Title in the Doxygen Configuration File?
How can I prevent freezing when using Task.Wait in C#?
What is the process to italicize certain keywords in visual studio code?