sign_planetary_computer: Signature in hrefs provided by the STAC from Microsoft's...

View source: R/signatures.R

sign_planetary_computerR Documentation

Signature in hrefs provided by the STAC from Microsoft's Planetary Computer.

Description

To perform the signing of the hrefs a request is sent to Planetary Computer servers and the returned content corresponds to the token that will be used in the href.

Usage

sign_planetary_computer(..., headers = NULL, token_url = NULL)

Arguments

...

additional parameters can be supplied to the GET function of the httr package.

headers

a named character vector with headers key-value content.

token_url

a character with the URL that generates the tokens in the Microsoft service. By default is used: "https://planetarycomputer.microsoft.com/api/sas/v1/token"

Value

a function that signs each item assets.

Examples

## Not run: 
 # STACItemCollection object
 stac_obj <- stac("https://planetarycomputer.microsoft.com/api/stac/v1/") %>%
  stac_search(collections = "sentinel-2-l2a",
              bbox = c(-47.02148, -17.35063, -42.53906, -12.98314)) %>%
  get_request()

 # signing each asset href
 stac_obj %>% items_sign(sign_fn = sign_planetary_computer())

 # example of access to collections that require authentication
 stac_obj <- stac("https://planetarycomputer.microsoft.com/api/stac/v1") %>%
   stac_search(collections = c("sentinel-1-rtc"),
               bbox = c(-64.8597, -10.4919, -64.79272527, -10.4473),
               datetime = "2019-01-01/2019-01-28") %>%
   post_request()

 # signing each asset href
 # stac_obj %>% items_sign(
 #   sign_fn = sign_planetary_computer(
 #     headers = c("Ocp-Apim-Subscription-Key" = <your-mpc-token>)
 #   )
 # )

## End(Not run)


rstac documentation built on Oct. 18, 2023, 1:15 a.m.