Client Login¶
The following tutorial will demonstrate how to use the Geneweaver Client package to log in to the Geneweaver API. This will allow you to access the Geneweaver API from the command line or from within a Python script.
The Geneweaver Client (geneweaver-client
) package is available on PyPI and can be
installed with pip or poetry. The package provides many useful functions for interacting
with Geneweaver from a client context, including utility functions to make
authentication simple.
This tutorial will demonstrate these utility functions from a Jupyter Notebook, but they can also be used from the command line or from within a Python script.
Install the geneweaver-client
package¶
In [ ]:
Copied!
!pip install geneweaver-client
!pip install geneweaver-client
In [2]:
Copied!
!gweave beta auth --help
!gweave beta auth --help
Usage: gweave beta auth [OPTIONS] COMMAND [ARGS]... The auth commands allow you to authenticate with the GeneWeaver API. ╭─ Options ────────────────────────────────────────────────────────────────────────╮ │ --help Show this message and exit. │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ╭─ Commands ───────────────────────────────────────────────────────────────────────╮ │ login Run the device authorization flow. │ │ print-access-token Print the current user's access token. │ │ print-identity-token Print the current user's identity token. │ ╰──────────────────────────────────────────────────────────────────────────────────╯
Login To Geneweaver¶
In [4]:
Copied!
!gweave beta auth login
!gweave beta auth login
1. On your computer or mobile device navigate to: https://geneweaver.auth0.com/activate?user_code=PNTH-VVCC 2. Enter the following code: PNTH-VVCC Authenticated! - Id Token: eyJhbGciOi...
In [5]:
Copied!
!gweave beta auth print-access-token
!gweave beta auth print-access-token
eyJhbGciOiJSUzI1...
In [6]:
Copied!
!gweave beta auth print-identity-token
!gweave beta auth print-identity-token
eyJhbGciOiJSUzI1...
In [7]:
Copied!
from geneweaver.client.auth import login
from geneweaver.client.auth import login
In [8]:
Copied!
# Run the login function and follow the link in the output.
# Confirm that the code matches the output here,
# then sign-up or login.
login()
# Wait for the "Authenticated!" message, then continue.
# Run the login function and follow the link in the output.
# Confirm that the code matches the output here,
# then sign-up or login.
login()
# Wait for the "Authenticated!" message, then continue.
1. On your computer or mobile device navigate to: https://geneweaver.auth0.com/activate?user_code=RNPC-MKQJ 2. Enter the following code: RNPC-MKQJ Authenticated! - Id Token: eyJhbGciOi...
In [12]:
Copied!
from geneweaver.client.auth import get_access_token
from geneweaver.client.auth import get_access_token
In [13]:
Copied!
get_access_token()
get_access_token()
Out[13]:
'eyJhbGciOiJSUzI1N...'