Skip to content

Commit 52bbc25

Browse files
author
Vsevolod
committed
secret description fixed
1 parent 2d5382e commit 52bbc25

File tree

4 files changed

+47
-52
lines changed

4 files changed

+47
-52
lines changed

module/move/gspread/.key/readme.md

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Getting API Keys for OAuth Authentication
2+
3+
Follow these steps to create and configure your OAuth credentials for using Google APIs.
4+
5+
## 1. Create API Credentials
6+
7+
1. Go to the [Google API Console](https://console.developers.google.com/).
8+
2. From the projects list, select an existing project or create a new one.
9+
3. In the left side menu, select **APIs & Services**.
10+
4. On the left menu, click **Credentials**.
11+
5. Click **Create Credentials** and select **OAuth client ID**.
12+
6. In the **Application type** section, select **Desktop app**.
13+
7. Provide an appropriate name for your client ID (e.g., "Gspread OAuth Client").
14+
8. Click **Create**.
15+
16+
Once the credential is created, you will receive a **Client ID** and **Client Secret**. These are required for accessing the API.
17+
18+
## 2. Store Your Credentials
19+
20+
Save the **Client ID** and **Client Secret** in a `.env` within a `.secret` directory. The file should look like this:
21+
22+
```bash
23+
CLIENT_ID=YOUR_CLIENT_ID
24+
CLIENT_SECRET=YOUR_SECRET_KEY
25+
```
26+
27+
28+
# Troubleshooting
29+
30+
If you encounter problems with authentication or tokens, you will most likely need to add **AUTH_URI** or **TOKEN_URI** to the .env file. To retrieve them, download the API key you created in JSON format. Open the file and copy the keys into the .env file. After making these changes, your .env file should look like this:
31+
32+
```bash
33+
CLIENT_ID=YOUR_CLIENT_ID
34+
CLIENT_SECRET=YOUR_SECRET_KEY
35+
AUTH_URI=YOUR_AUTH_URI
36+
TOKEN_URI=YOUR_TOKEN_URI
37+
```
38+
39+
If you still get some issues, follow [Google OAuth Documentation](https://developers.google.com/identity/protocols/oauth2/).

module/move/gspread/src/bin/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async fn main() -> Result< (), Box< dyn Error > >
1515
{
1616
dotenv().ok();
1717

18-
let secret = Secret::load()?;
18+
let secret = Secret::read();
1919

2020
let hub = hub( &secret ).await?;
2121

module/move/gspread/src/secret.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ mod private
5252
#[ allow( non_snake_case ) ]
5353
pub fn load() -> Result< Self >
5454
{
55-
let path = "./.key/-env.sh";
55+
let path = "./.secret/.env";
5656

5757
let r = dotenv::from_path( path );
5858
if let Err( ref err ) = r
@@ -67,8 +67,8 @@ mod private
6767
{
6868
CLIENT_SECRET : var( "CLIENT_SECRET", None )?,
6969
CLIENT_ID : var( "CLIENT_ID", None )?,
70-
AUTH_URI : var ( "AUTH_URI", None )?,
71-
TOKEN_URI : var ( "TOKEN_URI", None )?
70+
AUTH_URI : var ( "AUTH_URI", Some( "https://accounts.google.com/o/oauth2/auth" ) )?,
71+
TOKEN_URI : var ( "TOKEN_URI", Some( "https://oauth2.googleapis.com/token" ) )?
7272
};
7373
Ok( config )
7474
}
@@ -77,7 +77,7 @@ mod private
7777
{
7878
Self::load().unwrap_or_else( | err |
7979
{
80-
let example = include_str!("../.key/readme.md");
80+
let example = include_str!("../.secret/readme.md");
8181
let explanation = format!
8282
(
8383
r#" = Lack of secrets
@@ -87,7 +87,7 @@ Failed to load secret or some its parameters.
8787
8888
= Fix
8989
90-
Either define missing environment variable or make sure `./.key/-env.toml` file has it defined.
90+
Add missing secret to .env file in .secret directory. Example: MISSING_SECRET=YOUR_MISSING_SECRET
9191
9292
= More information
9393
@@ -109,10 +109,10 @@ Either define missing environment variable or make sure `./.key/-env.toml` file
109109
fn var
110110
(
111111
name : &'static str,
112-
default : Option<&'static str>,
112+
default : Option< &'static str >,
113113
) -> Result < String >
114114
{
115-
match env::var(name)
115+
match env::var( name )
116116
{
117117
Ok( val ) => Ok ( val ),
118118
Err( _ ) =>

0 commit comments

Comments
 (0)