Skip to content

Commit fe30b0d

Browse files
committed
Documentation cleanup and enhancements
- Fixed duplicate sections in README - Added JSON file credentials loading example to README - Fixed typos and corrected URLs in documentation - Removed empty/placeholder sections - Added scope customization as a TODO item - Fixed broken markdown link in STYLE.md
1 parent 4900d0d commit fe30b0d

File tree

4 files changed

+52
-53
lines changed

4 files changed

+52
-53
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ _scripts
5858
_cov_html
5959
secrets.json
6060
tokens.json
61-
TODO.mdø
61+
TODO.md
6262

README.md

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -94,58 +94,67 @@ client = FitbitClient(
9494
client_id="YOUR_CLIENT_ID",
9595
client_secret="YOUR_CLIENT_SECRET",
9696
redirect_uri="YOUR_REGISTERED_REDIRECT_URI",
97-
token_cache_path="/tmp/fb_tokens.json" # Optional: saves tokens between sessions
98-
redirect_uri="YOUR_REGISTERED_REDIRECT_URI",
99-
token_cache_path="/tmp/fb_tokens.json" # Optional: saves tokens between sessions
97+
token_cache_path="/tmp/fb_tokens.json"
10098
)
10199

102100
# Will open browser and handle callback automatically
103101
client.authenticate()
104102
```
105103

106-
The `token_cache_path` parameter allows you to persist authentication tokens
107-
between sessions. If provided, the client will:
104+
You can also load your credentials from a JSON file, which is useful for keeping
105+
secrets out of your code:
108106

109-
1. Load existing tokens from this file if available (avoiding re-authentication)
107+
```python
108+
from json import load
109+
from fitbit_client import FitbitClient
110110

111-
2. Save new or refreshed tokens to this file automatically
111+
# Load credentials from a JSON file
112+
with open("secrets.json") as f:
113+
secrets = load(f)
112114

113-
3. Handle token refresh when expired tokens are detected The `token_cache_path`
114-
parameter allows you to persist authentication tokens between sessions. If
115-
provided, the client will:
115+
# Initialize Fitbit OAuth2 flow and get a client
116+
client = FitbitClient(**secrets)
116117

117-
4. Load existing tokens from this file if available (avoiding re-authentication)
118+
# Authenticate as usual
119+
client.authenticate()
120+
```
118121

119-
5. Save new or refreshed tokens to this file automatically
122+
Where secrets.json contains:
120123

121-
6. Handle token refresh when expired tokens are detected
124+
```json
125+
{
126+
"client_id": "YOUR_CLIENT_ID",
127+
"client_secret": "YOUR_CLIENT_SECRET",
128+
"redirect_uri": "https://localhost:8080"
129+
}
130+
```
122131

123-
## Setting Up Your Fitbit App
132+
You can also include the optional token_cache_path:
124133

125-
1. Go to dev.fitbit.com and create a new application
126-
2. Set OAuth 2.0 Application Type to "Personal"
127-
3. Set Callback URL to "https://localhost:8080" (or your preferred local URL)
128-
4. Set Callback URL to "https://localhost:8080" (or your preferred local URL)
129-
5. Copy your Client ID and Client Secret
134+
```json
135+
{
136+
"client_id": "YOUR_CLIENT_ID",
137+
"client_secret": "YOUR_CLIENT_SECRET",
138+
"redirect_uri": "https://localhost:8080",
139+
"token_cache_path": "/tmp/tokens.json"
140+
}
141+
```
130142

131-
## Additional Documentation
143+
The `token_cache_path` parameter allows you to persist authentication tokens
144+
between sessions. If provided, the client will:
132145

133-
### For API Library Users
146+
1. Load existing tokens from this file if available (avoiding re-authentication)
134147

135-
- [LOGGING.md](docs/LOGGING.md): Understanding the dual-logger system
136-
- [TYPES.md](docs/TYPES.md): JSON type system and method return types
137-
- [NAMING.md](docs/NAMING.md): API method naming conventions
138-
- [VALIDATIONS.md](docs/VALIDATIONS.md): Input parameter validation
139-
- [ERROR_HANDLING.md](docs/ERROR_HANDLING.md): Exception hierarchy and handling
148+
2. Save new or refreshed tokens to this file automatically
140149

141-
It's also worth reviewing
142-
[Fitbit's Best Practices](https://dev.fitbit.com/build/reference/web-api/developer-guide/best-practices/)
143-
for API usage.
150+
3. Handle token refresh when expired tokens are detected
144151

145-
### Project Best Practices
152+
## Setting Up Your Fitbit App
146153

147-
- [DEVELOPMENT.md](docs/DEVELOPMENT.md): Development environment and guidelines
148-
- [STYLE.md](docs/STYLE.md): Code style and formatting standards
154+
1. Go to dev.fitbit.com and create a new application
155+
2. Set OAuth 2.0 Application Type to "Personal"
156+
3. Set Callback URL to "https://localhost:8080" (or your preferred local URL)
157+
4. Copy your Client ID and Client Secret
149158

150159
## Additional Documentation
151160

@@ -178,13 +187,6 @@ The methods are implemented in comments and should work, but I have not had a
178187
chance to verify them since this requires a publicly accessible server to
179188
receive webhook notifications.
180189

181-
If you're using this library with subscriptions and would like to help test and
182-
implement this functionality, please open an issue or pull request!
183-
[webhook subscriptions](https://dev.fitbit.com/build/reference/web-api/developer-guide/using-subscriptions/).
184-
The methods are implemented in comments and should work, but I have not had a
185-
chance to verify them since this requires a publicly accessible server to
186-
receive webhook notifications.
187-
188190
If you're using this library with subscriptions and would like to help test and
189191
implement this functionality, please open an issue or pull request!
190192

docs/DEVELOPMENT.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
1. Clone the repository:
4646

4747
```bash
48-
git clone https://github.com/yourusername/fitbit-client.git
49-
cd fitbit-client
48+
git clone https://github.com/jpstroop/fitbit-client-python.git
49+
cd fitbit-client-python
5050
```
5151

5252
2. Install asdf plugins and required versions:
@@ -129,8 +129,8 @@ import typing
129129
import datetime
130130
```
131131

132-
The one excpetion to this rule is when an entire module needs to be `mock`ed for
133-
testing, in which case, at least for the `json` package from the standare
132+
The one exception to this rule is when an entire module needs to be `mock`ed for
133+
testing, in which case, at least for the `json` package from the standard
134134
library, the entire package has to be imported. So `import json` is ok when that
135135
circumstance arises.
136136

@@ -378,10 +378,6 @@ The OAuth callback mechanism is implemented using two main classes:
378378
- Removing temporary certificate files
379379
- Clearing internal state
380380

381-
### Security Notes
382-
383-
TODO
384-
385381
## Git Workflow
386382

387383
1. Create a new branch for your feature/fix
@@ -391,7 +387,8 @@ TODO
391387

392388
## Release Process
393389

394-
TODO
390+
The release process will be documented as the project nears its first public
391+
release.
395392

396393
## Getting Help
397394

docs/STYLE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
Linting and formatting are handled by [Black](https://github.com/psf/black),
44
[isort](https://github.com/pycqa/isort/),
5-
[mdformat](https://github.com/pycqa/isort/),
6-
[autoflake](https://github.com/PyCQA/autoflake) and a \[small script that adds a
7-
path comment)[lint/add_file_headers.py]. That said, here are some general
8-
guidelines:
5+
[mdformat](https://github.com/executablebooks/mdformat),
6+
[autoflake](https://github.com/PyCQA/autoflake) and a
7+
[small script that adds a path comment](/lint/add_file_headers.py). That said,
8+
here are some general guidelines:
99

1010
## Code Organization and Structure
1111

0 commit comments

Comments
 (0)