-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix: add form encode #18
base: master
Are you sure you want to change the base?
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.
I've tested this and it worked fine. I first got directed to a webpage that informed me that they would send me an email to confirm I am who I say I am. This took a few mins, but once I confimed the process completed and I received the token.
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.
To be consistent, we could all use the 'styler' R package to style our R code based on the same guidelines.
I dirty changed my testscript into Not sure how to move that into the tryCatch test script# Manual test
library(MolgenisArmadillo)
#library(MolgenisAuth)
source("R/auth.R")
url <- "https://auth.molgenis.org"
url <- "https://auth1.molgenis.net/realms/Molgenis"
client_id <- "Dev-Armadillo-Test"
#browser()
endpoint <- discover(url)
endpoint
encode <- "json"
credentials <- NULL
#credentials <- device_flow_auth(endpoint, client_id, encode=encode)
tryCatch(credentials <- device_flow_auth(endpoint, client_id, encode='json'),
finally = tryCatch(credentials <- device_flow_auth(endpoint, client_id, encode='form'),
finally = credentials <- NULL)
)
credentials$id_token |
Trying to fix in auth.R using nested tryCatch POST using
encode <- NULL
tryCatch({
encode = "json"
response <- httr::POST(endpoint$device,
encode = encode,
body = list(
client_id = client_id,
scope = paste(scopes, collapse = " ")
)
)
}, error = tryCatch({
encode <- "form"
response <- httr::POST(endpoint$device,
encode = encode,
body = list(
client_id = client_id,
scope = paste(scopes, collapse = " ")
)
)
})
) |
How about something like this:
Possible advantages
Disadvantages
|
REF T#9849
KeyCloak
For fetching device token from a KeyCloak server we need to use form encoding.
Initial idea
Better alternative
Use the
tryCatch
from comment below. From first approach nesting is bad and bailing out still not understood...ByEncoding
for the first POSTjson
first as that's the default for calling...ByEncoding
form
and retry calling...ByEncoding
How to test
Checking server capabilities
This does not reveil choosing between
json
orform
form
in json section ".response_modes_supported" and there is no request related fieldAffects