Skip to content

Commit

Permalink
feat(backend): remove the google books API key
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Aug 25, 2024
1 parent 82e86cb commit ff3778a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ jobs:
APP_VERSION: ${{ steps.build.outputs.version }}
DEFAULT_TMDB_ACCESS_TOKEN: ${{ secrets.DEFAULT_TMDB_ACCESS_TOKEN }}
DEFAULT_MAL_CLIENT_ID: ${{ secrets.DEFAULT_MAL_CLIENT_ID }}
DEFAULT_GOOGLE_BOOKS_API_KEY: ${{ secrets.DEFAULT_GOOGLE_BOOKS_API_KEY }}
run: |
${{ matrix.platform.command }} build --locked --target ${{ matrix.platform.target }} --release
- name: Upload build artifact
Expand Down
1 change: 0 additions & 1 deletion Cross.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ passthrough = [
"APP_VERSION",
"DEFAULT_TMDB_ACCESS_TOKEN",
"DEFAULT_MAL_CLIENT_ID",
"DEFAULT_GOOGLE_BOOKS_API_KEY",
]

[build]
Expand Down
11 changes: 0 additions & 11 deletions crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ fn default_mal_client_id(_ctx: &()) -> Result<Option<String>, HandlerError> {
Ok(Some(DEFAULT_MAL_CLIENT_ID.to_owned()))
}

#[cfg(debug_assertions)]
pub const DEFAULT_GOOGLE_BOOKS_API_KEY: &str =
dotenvy_macro::dotenv!("DEFAULT_GOOGLE_BOOKS_API_KEY");
#[cfg(not(debug_assertions))]
pub const DEFAULT_GOOGLE_BOOKS_API_KEY: &str = env!("DEFAULT_GOOGLE_BOOKS_API_KEY");

fn default_google_books_api_key(_ctx: &()) -> Result<Option<String>, HandlerError> {
Ok(Some(DEFAULT_GOOGLE_BOOKS_API_KEY.to_owned()))
}

#[derive(Debug, Serialize, Deserialize, Clone, Config)]
#[config(rename_all = "snake_case", env_prefix = "ANIME_AND_MANGA_MAL_")]
pub struct MalConfig {
Expand Down Expand Up @@ -123,7 +113,6 @@ pub struct OpenlibraryConfig {
#[config(rename_all = "snake_case", env_prefix = "BOOKS_GOOGLE_BOOKS_")]
pub struct GoogleBooksConfig {
/// The API key to be used for the Google Books API.
#[setting(default = default_google_books_api_key)]
pub api_key: String,
/// Whether to pass the raw query string to the search API.
pub pass_raw_query: bool,
Expand Down
32 changes: 32 additions & 0 deletions docs/content/guides/books.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Books

A guide about books integration for Ryot.

## Integration with Google Books

Ryot also supports tracking books via [Google Books](https://books.google.com). However,
the API is heavily rate limited, so it is not possible to hardcode the API keys in the
application (unlike the others).

You can follow the below steps to obtain your own API keys and enable book tracking with
Google Books.

### Steps

1. Create a [Google Cloud Platform](https://cloud.google.com) account. Open your [Google
Cloud Platform Console](https://console.cloud.google.com).

2. Use the default project or click on "Create a project" on the dashboard.

3. Open the [APIs & Services Dashboard](https://console.cloud.google.com/apis/dashboard).

4. Click on "Enable APIs and Services". Search for "Google Books API" and click on
"Enable".

5. Click on "Credentials" on the left sidebar. Click on "Create Credentials" and select
"API key".

6. Click on "Create" and copy the API key.

7. Set the `books.google_books.api_key` configuration variable in the environment as
described in the [configuration](../configuration.md#important-parameters) docs.

0 comments on commit ff3778a

Please sign in to comment.