---
title: "Credentials and configuration"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Credentials and configuration}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
```

Credentials in Ropendal are passed explicitly through `auth =` to make
visibility and testability straightforward.

## S3-compatible examples

```{r, eval = FALSE}
fs <- opendal(
  "s3",
  endpoint = "https://s3.amazonaws.com",
  bucket = "my-bucket",
  region = "us-east-1",
  auth = credentials_s3(
    access_key_id = "AKIA...",
    secret_access_key = "secret..."
  )
)
```

## Google Drive

```{r, eval = FALSE}
gdrive_fs <- opendal(
  "gdrive",
  root = "Projects",
  auth = credentials_gdrive(access_token = "ya29...", refresh_token = "....")
)
```

## Azure Blob / GCS helpers

```{r, eval = FALSE}
fs_gcs <- opendal(
  "gcs",
  bucket = "my-gcs-bucket",
  auth = credentials_gcs(token = "ya29...")
)

fs_az <- opendal(
  "azblob",
  container = "my-container",
  auth = credentials_azblob(account_name = "acct", account_key = "key...")
)
```

Use `credentials_gdrive3()` when you already use gdrive JSON token files.

```{r, eval = FALSE}
fs_gdrive3 <- opendal(
  "gdrive",
  root = "Ropendal",
  auth = credentials_gdrive3(
    secret_json = "/path/secret.json",
    tokens_json = "/path/tokens.json"
  )
)
```
