-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #402 from scottbarnes/documentation/add-local-dev-…
…authentication-steps Documentation: add local dev authentication steps
- Loading branch information
Showing
1 changed file
with
17 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,10 @@ $ pipx install git+https://github.com/internetarchive/openlibrary-client.git | |
``` | ||
__-- or --__ | ||
``` | ||
pip install git+https://github.com/internetarchive/openlibrary-client.git | ||
``` | ||
__-- or --__ | ||
``` | ||
$ git clone https://github.com/internetarchive/openlibrary-client.git | ||
$ cd openlibrary-client | ||
$ pip install . | ||
|
@@ -27,25 +31,35 @@ $ pipx install git+https://github.com/internetarchive/openlibrary-client.git | |
``` | ||
|
||
## Configuration | ||
### Authentication Against Production | ||
|
||
Many Open Library actions (like creating Works and Editions) require authentication, i.e. certain requests must be provided a valid cookie of a user which has been logged in with their openlibrary account credentials. The openlibrary-client can be configured to "remember you" so you don't have to provide credentials with each request. | ||
|
||
First time users may run the following command to enable the "remember me" feature. This process will ask for an **Archive.org email and password**, will authenticate the credentials, and then store the account's corresponding s3 keys in `~/.config/ol.ini` (or whichever config location the user has specified): | ||
|
||
``` | ||
```sh | ||
$ ol --configure --email [email protected] | ||
password: *********** | ||
Successfully configured | ||
``` | ||
|
||
### Using Keys Directly | ||
#### Using Keys Directly | ||
The ol.ini has two variables, access and secret. If you have both of them, you can manually initialise them | ||
``` | ||
```python | ||
from olclient import OpenLibrary, config | ||
ol = OpenLibrary(credentials=config.Credentials(access='<access>', secret='<secret>')) | ||
``` | ||
This way, access and secret can be pulled from environment variables at runtime! | ||
|
||
### Authentication Against the Local Development Environment | ||
```python | ||
from olclient import OpenLibrary | ||
from collections import namedtuple | ||
Credentials = namedtuple("Credentials", ["username", "password"]) | ||
credentials = Credentials("[email protected]", "admin123") | ||
ol = OpenLibrary(base_url="http://localhost:8080", credentials=credentials) | ||
``` | ||
|
||
## Usage | ||
|
||
### Python Library | ||
|