-
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
OAuth Copernicus API #563
Comments
Are you sure you are supposed to set |
And is there a reason you're not using |
@jeroen Yes, in their example, they set |
To mimic the python example, you need to use library(httr2)
## Read the keys created at step 2.1
service_key = jsonlite::read_json("./land-copernicus.json")
private_key = service_key[["private_key"]]
## Create the authorisation grant from private key
claim = jwt_claim(
iss = service_key[["client_id"]],
sub = service_key[["user_id"]],
aud = service_key[["token_uri"]],
iat = Sys.time(),
exp = Sys.time() + 60*60 # Gives an expiration date of one hour (the maximum authorised)
)
grant = jose::jwt_encode_sig(claim, private_key)
req = request(base_url = service_key[["token_uri"]]) |>
req_body_form(grant_type = "urn:ietf:params:oauth:grant-type:jwt-bearer", assertion = grant) |>
req_perform(verbosity = 2)
resp_body_json(req) Not sure if this is the same as |
Many thanks, that worked! I just add the reference #522 as it could be an example with a free API and an OAuth |
Hello,
I am trying to connect to the Copernicus Land Monitoring Service API (see stack overflow question for more details on R code)
When I use
I get errors in both cases. With req, I get:
and with req2:
I do not understand given that I put both a
grant_type
and the algorithmRS256
.I generated the grant with Python with the following code, copy-pasted the grant in R, and it worked:
Any idea of where could be the problem? Many thanks
The text was updated successfully, but these errors were encountered: