From 7d086d4c47d61d7a29e35dd3e8510a36d46bd05b Mon Sep 17 00:00:00 2001 From: Florent Ravenel Date: Sun, 8 Oct 2023 09:45:57 +0200 Subject: [PATCH] feat(Appwrite): Add User Authentication --- Appwrite/Appwrite_User_Authentication.ipynb | 318 ++++++++++++++++++++ 1 file changed, 318 insertions(+) create mode 100644 Appwrite/Appwrite_User_Authentication.ipynb diff --git a/Appwrite/Appwrite_User_Authentication.ipynb b/Appwrite/Appwrite_User_Authentication.ipynb new file mode 100644 index 0000000000..6fd6562227 --- /dev/null +++ b/Appwrite/Appwrite_User_Authentication.ipynb @@ -0,0 +1,318 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "6c4c63ae-5034-4150-8f7a-1541968c6913", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Naas\"" + ] + }, + { + "cell_type": "markdown", + "id": "8d64ced2-e7f3-442a-a3ec-8af66a99184e", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# Appwrite - User Authentication" + ] + }, + { + "cell_type": "markdown", + "id": "bf188fc8-9ea3-4853-ae06-06c3fe162226", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #appwrite #python #sdk #authentication #user #create" + ] + }, + { + "cell_type": "markdown", + "id": "f122d69a-ae50-4d95-90df-fcb0d483fac7", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Firstname Lastname]()" + ] + }, + { + "cell_type": "markdown", + "id": "6f8a21c1-560a-405f-8599-fd906e95673d", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2023-10-08 (Created: 2023-10-08)" + ] + }, + { + "cell_type": "markdown", + "id": "96df94c1-842e-4588-a304-7b28a281138e", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Description:** This notebook will demonstrate how to use the Appwrite Python SDK to create a authentication and have options to `create_user`, `delete_user`, `list_all_users` as individual routines. It is usefull for organizations that need to manage user authentication." + ] + }, + { + "cell_type": "markdown", + "id": "a14df074-778c-4f39-bc9e-c53d907dc830", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**References:**\n- [Appwrite Python SDK](https://github.com/appwrite/sdk-for-python)\n- [Appwrite Documentation](https://appwrite.io/docs)" + ] + }, + { + "cell_type": "markdown", + "id": "2bfe3fda-6f51-45b4-8dfa-06dda53622b2", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "4f245a0a-f3a4-4750-be9c-752a07e7e4b5", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "81730041-2523-462e-83c7-f3c08a3ca960", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": "import appwrite", + "outputs": [] + }, + { + "cell_type": "markdown", + "id": "54602e57-1b2f-4acb-9f32-eb5ec0561582", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n- `endpoint`: Appwrite endpoint URL\n- `project`: Appwrite project ID\n- `key`: Appwrite secret key" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "69019e17-53eb-434a-8837-ab33b6a5d0ce", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": "endpoint = \"https://appwrite.io/v1\"\nproject = \"5f5d7e7c2c7d3\"\nkey = \"5f5d7e7c2c7d3\"", + "outputs": [] + }, + { + "cell_type": "markdown", + "id": "57e10eba-26ba-49f5-8376-02be391a8edd", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "a93a0eb3-c7a1-467b-bb94-18e4c331d3ca", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Create User" + ] + }, + { + "cell_type": "markdown", + "id": "8b6f611f-d15f-4d32-af30-9193a401fdd5", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "This routine will create a new user in the Appwrite project." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b26699a4-fa18-4658-90bc-b3c3e7fd68f4", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": "# Initialize Appwrite client\nclient = appwrite.Client()\nclient.set_endpoint(endpoint)\nclient.set_project(project)\nclient.set_key(key)\n# Create user\nclient.users.create(\"John\", \"Doe\", \"john@example.com\", \"password\")", + "outputs": [] + }, + { + "cell_type": "markdown", + "id": "cbc58c00-2d7f-4cc7-9dc8-6e097765b402", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Delete User" + ] + }, + { + "cell_type": "markdown", + "id": "e6394964-2012-48e5-83e0-726b49934bb0", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "This routine will delete an existing user in the Appwrite project." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f7aad6fd-c8b4-44a0-8ff6-0d9139412fd6", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": "# Initialize Appwrite client\nclient = appwrite.Client()\nclient.set_endpoint(endpoint)\nclient.set_project(project)\nclient.set_key(key)\n# Delete user\nclient.users.delete(\"john@example.com\")", + "outputs": [] + }, + { + "cell_type": "markdown", + "id": "7d069786-1b78-4507-ab15-3096ef91c7ac", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### List All Users" + ] + }, + { + "cell_type": "markdown", + "id": "36219a1d-932b-4ca6-8759-e279cbe46f4c", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "This routine will list all users in the Appwrite project." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "902a1c53-f8a0-490c-9104-33583714391e", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": "# Initialize Appwrite client\nclient = appwrite.Client()\nclient.set_endpoint(endpoint)\nclient.set_project(project)\nclient.set_key(key)\n# List all users\nclient.users.list()", + "outputs": [] + }, + { + "cell_type": "markdown", + "id": "184899cb-5d16-4fca-b391-8091097faeb7", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "1761131b-d9c4-4fa1-85ae-02ea2ff9c8ea", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "daf7aece-d7c1-484f-9dee-a1130e5a9489", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": "# Display result\nprint(client.users.list())", + "outputs": [] + }, + { + "cell_type": "markdown", + "id": "5357eaf0-db18-49ec-9548-ef58e9817eeb", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + " " + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} \ No newline at end of file