-
Notifications
You must be signed in to change notification settings - Fork 0
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 #27 from TheJacksonLaboratory/task/add-client-logi…
…n-tutorial Adding geneweaver client login tutorial
- Loading branch information
Showing
2 changed files
with
273 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,272 @@ | ||
{ | ||
"nbformat": 4, | ||
"nbformat_minor": 0, | ||
"metadata": { | ||
"colab": { | ||
"provenance": [] | ||
}, | ||
"kernelspec": { | ||
"name": "python3", | ||
"display_name": "Python 3" | ||
}, | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"# Client Login\n", | ||
"\n", | ||
"The following tutorial will demonstrate how to use the Geneweaver Client package to log\n", | ||
"in to the Geneweaver API. This will allow you to access the Geneweaver API from the\n", | ||
"command line or from within a Python script.\n", | ||
"\n", | ||
"The Geneweaver Client (`geneweaver-client`) package is available on PyPI and can be\n", | ||
"installed with pip or poetry. The package provides many useful functions for interacting\n", | ||
"with Geneweaver from a client context, including utility functions to make\n", | ||
"authentication simple.\n", | ||
"\n", | ||
"This tutorial will demonstrate these utility functions from a Jupyter Notebook, but they\n", | ||
"can also be used from the command line or from within a Python script.\n", | ||
"\n", | ||
"\n", | ||
"###Install the `geneweaver-client` package" | ||
], | ||
"metadata": { | ||
"id": "qXfFhL8myKJd" | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"id": "Hs7pLPIhx7fE" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"!pip install geneweaver-client" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"## Using The Command Line Client\n", | ||
"### Access Help Documentation" | ||
], | ||
"metadata": { | ||
"id": "HIBxnwBPyWwc" | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"!gweave beta auth --help" | ||
], | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/" | ||
}, | ||
"id": "5mrdO2jjx-LQ", | ||
"outputId": "45579f02-5f98-4657-fd8b-16b6c45da569" | ||
}, | ||
"execution_count": 2, | ||
"outputs": [ | ||
{ | ||
"output_type": "stream", | ||
"name": "stdout", | ||
"text": [ | ||
"\u001B[1m \u001B[0m\n", | ||
"\u001B[1m \u001B[0m\u001B[1;33mUsage: \u001B[0m\u001B[1mgweave beta auth [OPTIONS] COMMAND [ARGS]...\u001B[0m\u001B[1m \u001B[0m\u001B[1m \u001B[0m\n", | ||
"\u001B[1m \u001B[0m\n", | ||
" The auth commands allow you to authenticate with the GeneWeaver API. \n", | ||
" \n", | ||
"\u001B[2m╭─\u001B[0m\u001B[2m Options \u001B[0m\u001B[2m───────────────────────────────────────────────────────────────────────\u001B[0m\u001B[2m─╮\u001B[0m\n", | ||
"\u001B[2m│\u001B[0m \u001B[1;36m-\u001B[0m\u001B[1;36m-help\u001B[0m Show this message and exit. \u001B[2m│\u001B[0m\n", | ||
"\u001B[2m╰──────────────────────────────────────────────────────────────────────────────────╯\u001B[0m\n", | ||
"\u001B[2m╭─\u001B[0m\u001B[2m Commands \u001B[0m\u001B[2m──────────────────────────────────────────────────────────────────────\u001B[0m\u001B[2m─╮\u001B[0m\n", | ||
"\u001B[2m│\u001B[0m \u001B[1;36mlogin \u001B[0m\u001B[1;36m \u001B[0m Run the device authorization flow. \u001B[2m│\u001B[0m\n", | ||
"\u001B[2m│\u001B[0m \u001B[1;36mprint-access-token \u001B[0m\u001B[1;36m \u001B[0m Print the current user's access token. \u001B[2m│\u001B[0m\n", | ||
"\u001B[2m│\u001B[0m \u001B[1;36mprint-identity-token \u001B[0m\u001B[1;36m \u001B[0m Print the current user's identity token. \u001B[2m│\u001B[0m\n", | ||
"\u001B[2m╰──────────────────────────────────────────────────────────────────────────────────╯\u001B[0m\n", | ||
"\n" | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### Login To Geneweaver" | ||
], | ||
"metadata": { | ||
"id": "U2Xelf5Xyk1x" | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"!gweave beta auth login" | ||
], | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/" | ||
}, | ||
"id": "IDPInF0WyhGf", | ||
"outputId": "53bad9b8-e0c8-458d-ecd2-9d056859f400" | ||
}, | ||
"execution_count": 4, | ||
"outputs": [ | ||
{ | ||
"output_type": "stream", | ||
"name": "stdout", | ||
"text": [ | ||
"1. On your computer or mobile device navigate to: https://geneweaver.auth0.com/activate?user_code=PNTH-VVCC\n", | ||
"2. Enter the following code: PNTH-VVCC\n", | ||
"Authenticated!\n", | ||
"- Id Token: eyJhbGciOi...\n" | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"!gweave beta auth print-access-token" | ||
], | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/" | ||
}, | ||
"id": "nuOAds5gyqqY", | ||
"outputId": "32c37920-daff-4547-c62b-84a902191944" | ||
}, | ||
"execution_count": 5, | ||
"outputs": [ | ||
{ | ||
"output_type": "stream", | ||
"name": "stdout", | ||
"text": [ | ||
"eyJhbGciOiJSUzI1...\n" | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"!gweave beta auth print-identity-token" | ||
], | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/" | ||
}, | ||
"id": "x62YK2twzR8J", | ||
"outputId": "51f064f2-811b-4743-f6b1-b42c636f5241" | ||
}, | ||
"execution_count": 6, | ||
"outputs": [ | ||
{ | ||
"output_type": "stream", | ||
"name": "stdout", | ||
"text": [ | ||
"eyJhbGciOiJSUzI1...\n" | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"## Using The Python Package\n", | ||
"### Login To Geneweaver" | ||
], | ||
"metadata": { | ||
"id": "vZf6SfxrzZMX" | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"from geneweaver.client.auth import login" | ||
], | ||
"metadata": { | ||
"id": "wQWHglhJzha6" | ||
}, | ||
"execution_count": 7, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"# Run the login function and follow the link in the output.\n", | ||
"# Confirm that the code matches the output here,\n", | ||
"# then sign-up or login.\n", | ||
"login()\n", | ||
"# Wait for the \"Authenticated!\" message, then continue." | ||
], | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/" | ||
}, | ||
"id": "f_8mne96zt8d", | ||
"outputId": "469ffac6-a789-41e7-b6f2-18547b31628e" | ||
}, | ||
"execution_count": 8, | ||
"outputs": [ | ||
{ | ||
"output_type": "stream", | ||
"name": "stdout", | ||
"text": [ | ||
"1. On your computer or mobile device navigate to: https://geneweaver.auth0.com/activate?user_code=RNPC-MKQJ\n", | ||
"2. Enter the following code: RNPC-MKQJ\n", | ||
"Authenticated!\n", | ||
"- Id Token: eyJhbGciOi...\n" | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"from geneweaver.client.auth import get_access_token" | ||
], | ||
"metadata": { | ||
"id": "8knTLojQzxIs" | ||
}, | ||
"execution_count": 12, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"get_access_token()" | ||
], | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/", | ||
"height": 105 | ||
}, | ||
"id": "2SSTSFVkz1EF", | ||
"outputId": "756d5123-45fa-47c9-b471-1f3734df3ba9" | ||
}, | ||
"execution_count": 13, | ||
"outputs": [ | ||
{ | ||
"output_type": "execute_result", | ||
"data": { | ||
"text/plain": [ | ||
"'eyJhbGciOiJSUzI1N...'" | ||
], | ||
"application/vnd.google.colaboratory.intrinsic+json": { | ||
"type": "string" | ||
} | ||
}, | ||
"metadata": {}, | ||
"execution_count": 13 | ||
} | ||
] | ||
} | ||
] | ||
} |
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