Skip to content
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

Make OAuth default provider #39

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions docs/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ hide_title: true

<Alert status="warning">

**🚧 WARNING - Work in Progress 🚧**
**🚧 WARNING - Experimental 🚧**

Here be many dragons
Here be dragons
</Alert>


A DuckDB extension that allows you to read and write Google Sheets using SQL.
A DuckDB extension for reading and writing Google Sheets with SQL.

Note: This project is not affliated with Google or DuckDB.
_Note: This project is not affliated with Google or DuckDB, it is a community extensionmaintained by [Evidence](https://evidence.dev)._

## Install

Expand All @@ -31,11 +31,15 @@ The latest version of DuckDB (currently 1.1.2) is required.
### Authenticate

```sql
-- Authenticate with Google Account in the browser (easiest)
CREATE SECRET (TYPE gsheet, PROVIDER oauth);
-- Authenticate with Google Account in the browser (default)
CREATE SECRET (TYPE gsheet);

-- OR create a secret with your Google API access token (boring, see below guide)
CREATE SECRET (TYPE gsheet, TOKEN '<your_token>');
CREATE SECRET (
TYPE gsheet,
PROVIDER access_token,
TOKEN '<your_token>'
);
```

### Read
Expand Down Expand Up @@ -103,7 +107,6 @@ This token will periodically expire - you can re-run the above command again to
## Limitations / Known Issues

- Google Sheets has a limit of 1,000,000 cells per spreadsheet.
- The OAuth app has not yet been approved by Google, so will throw a warning - you must select "Contine (Unsafe)" to use it.
- Reading sheets where data does not start in A1 is not yet supported.
- Writing data to a sheet starting from a cell other than A1 is not yet supported.
- Sheets must already exist to COPY TO them.
2 changes: 1 addition & 1 deletion src/gsheets_auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace duckdb
SecretType secret_type;
secret_type.name = type;
secret_type.deserializer = KeyValueSecret::Deserialize<KeyValueSecret>;
secret_type.default_provider = "access_token";
secret_type.default_provider = "oauth";
ExtensionUtil::RegisterSecretType(instance, secret_type);

// Register the access_token secret provider
Expand Down
6 changes: 5 additions & 1 deletion test/sql/copy_to.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ require gsheets

# Create a secret NB must substitute a token, do not commit!
statement ok
create secret test_secret (type gsheet, token '${TOKEN}');
create secret test_secret (
type gsheet,
provider access_token,
token '${TOKEN}'
);

# Create a table to copy to Google Sheet
statement ok
Expand Down
6 changes: 5 additions & 1 deletion test/sql/read_gsheet.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ require gsheets

# Create a secret NB must substitute a token, do not commit!
statement ok
create secret test_secret (type gsheet, token '${TOKEN}');
create secret test_secret (
type gsheet,
provider access_token,
token '${TOKEN}'
);

# Confirm the extension works
query III
Expand Down
Loading