From 8066a0fcc6aae53d4f21a267ab8eb08ea631b869 Mon Sep 17 00:00:00 2001 From: M Sai Kiran Date: Thu, 12 Oct 2023 16:19:43 +0200 Subject: [PATCH] revised --- Appwrite/Appwrite_User_Authentication.ipynb | 172 +++++++++++++++++--- 1 file changed, 151 insertions(+), 21 deletions(-) diff --git a/Appwrite/Appwrite_User_Authentication.ipynb b/Appwrite/Appwrite_User_Authentication.ipynb index 8ba72aa087..089d03812c 100644 --- a/Appwrite/Appwrite_User_Authentication.ipynb +++ b/Appwrite/Appwrite_User_Authentication.ipynb @@ -103,16 +103,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "81730041-2523-462e-83c7-f3c08a3ca960", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-12T14:00:10.075663Z", + "iopub.status.busy": "2023-10-12T14:00:10.075439Z", + "iopub.status.idle": "2023-10-12T14:00:11.893615Z", + "shell.execute_reply": "2023-10-12T14:00:11.892973Z", + "shell.execute_reply.started": "2023-10-12T14:00:10.075640Z" + }, "papermill": {}, "tags": [] }, "outputs": [], "source": [ - "from appwrite.client import Client\n", - "from appwrite.services.users import Users" + "try:\n", + " from appwrite.client import Client\n", + " from appwrite.services.users import Users\n", + "except ImportError:\n", + " !pip install appwrite\n", + " from appwrite.client import Client\n", + " from appwrite.services.users import Users\n", + "try:\n", + " import naas\n", + "except:\n", + " !pip install naas\n", + " import naas" ] }, { @@ -131,18 +148,44 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "id": "69019e17-53eb-434a-8837-ab33b6a5d0ce", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-12T14:14:15.011512Z", + "iopub.status.busy": "2023-10-12T14:14:15.011285Z", + "iopub.status.idle": "2023-10-12T14:14:16.013409Z", + "shell.execute_reply": "2023-10-12T14:14:16.012814Z", + "shell.execute_reply.started": "2023-10-12T14:14:15.011490Z" + }, "papermill": {}, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "👌 Well done! Your Secret has been sent to production. \n", + "\n", + "PS: to remove the \"Secret\" feature, just replace .add by .delete\n", + "👌 Well done! Your Secret has been sent to production. \n", + "\n", + "PS: to remove the \"Secret\" feature, just replace .add by .delete\n", + "👌 Well done! Your Secret has been sent to production. \n", + "\n", + "PS: to remove the \"Secret\" feature, just replace .add by .delete\n" + ] + } + ], "source": [ - "endpoint = \"https://cloud.appwrite.io/v1\" #replace with your end-point here.\n", - "project = \"6526da963cd09677a562\" #replace with your project here.\n", - "key = \"04e727e29a0d284ef05a9206ab13d288fff61f96193962fe3c9238c116cdd935e77c4dbecf6ef16d3d485a1d48c202b4cad3b16a4dd30847e218b6ebbfec341ab62fdacd29616030ce16b8093c677e1f615f59588a1b58e32d488e60b6b04736f792f6b3e8cbe2e03bf447245a87913f38aac111a7b53cf59c68831e02d732d8\"\n", - "#replace key with your key." + "# replace endpoint , project , key with your credentials.\n", + "naas.secret.add(name=\"endpoint\",secret=\"https://cloud.appwrite.io/v1\")\n", + "naas.secret.add(name=\"project\",secret=\"6526da963cd09677a562\")\n", + "naas.secret.add(name=\"key\",secret=\"04e727e29a0d284ef05a9206ab13d288fff61f96193962fe3c9238c116cdd935e77c4dbecf6ef16d3d485a1d48c202b4cad3b16a4dd30847e218b6ebbfec341ab62fdacd29616030ce16b8093c677e1f615f59588a1b58e32d488e60b6b04736f792f6b3e8cbe2e03bf447245a87913f38aac111a7b53cf59c68831e02d732d8\")\n", + "endpoint = naas.secret.get(name=\"endpoint\")\n", + "project = naas.secret.get(name=\"project\")\n", + "key = naas.secret.get(name=\"key\")" ] }, { @@ -180,13 +223,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "id": "b26699a4-fa18-4658-90bc-b3c3e7fd68f4", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-12T14:14:03.755902Z", + "iopub.status.busy": "2023-10-12T14:14:03.755632Z", + "iopub.status.idle": "2023-10-12T14:14:04.193325Z", + "shell.execute_reply": "2023-10-12T14:14:04.192614Z", + "shell.execute_reply.started": "2023-10-12T14:14:03.755877Z" + }, "papermill": {}, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "User Created!\n", + "User Details:\n", + "User ID: msaik12\n", + "Name: \n", + "Email: email@example.com\n", + "Phone: +1234456666\n", + "Registration Date: 2023-10-12T14:14:04.155+00:00\n", + "Status: Active\n" + ] + } + ], "source": [ "# Initialize Appwrite client\n", "client = Client()\n", @@ -212,9 +277,7 @@ " print(f\"Registration Date: {user_details['registration']}\")\n", " print(f\"Status: {'Active' if user_details['status'] else 'Inactive'}\")\n", "except: #make sure to provide different username everytime creating the user!\n", - " print(\"User not created !\")\n", - "# print(response)\n", - "# Print user details in a formatted way" + " print(\"User not created !\")" ] }, { @@ -241,13 +304,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "id": "f7aad6fd-c8b4-44a0-8ff6-0d9139412fd6", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-12T14:13:54.332745Z", + "iopub.status.busy": "2023-10-12T14:13:54.332521Z", + "iopub.status.idle": "2023-10-12T14:13:54.630645Z", + "shell.execute_reply": "2023-10-12T14:13:54.630059Z", + "shell.execute_reply.started": "2023-10-12T14:13:54.332722Z" + }, "papermill": {}, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "user deleted !\n" + ] + } + ], "source": [ "#We already initialised the Appwrite client in the above cells\n", "# Delete user that's created above.\n", @@ -282,13 +360,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "id": "902a1c53-f8a0-490c-9104-33583714391e", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-12T14:14:07.204318Z", + "iopub.status.busy": "2023-10-12T14:14:07.204088Z", + "iopub.status.idle": "2023-10-12T14:14:07.395495Z", + "shell.execute_reply": "2023-10-12T14:14:07.394763Z", + "shell.execute_reply.started": "2023-10-12T14:14:07.204297Z" + }, "papermill": {}, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "User Details:\n", + "User ID: msaik12\n", + "Name: \n", + "Email: email@example.com\n", + "Phone: +1234456666\n", + "Registration Date: 2023-10-12T14:14:04.155+00:00\n", + "Status: Active\n", + "---\n" + ] + } + ], "source": [ "# List all users\n", "x=users.list()\n", @@ -328,13 +428,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "id": "daf7aece-d7c1-484f-9dee-a1130e5a9489", "metadata": { + "execution": { + "iopub.execute_input": "2023-10-12T14:15:53.158786Z", + "iopub.status.busy": "2023-10-12T14:15:53.158557Z", + "iopub.status.idle": "2023-10-12T14:15:53.519508Z", + "shell.execute_reply": "2023-10-12T14:15:53.518853Z", + "shell.execute_reply.started": "2023-10-12T14:15:53.158763Z" + }, "papermill": {}, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "User Details:\n", + "User ID: msaik12\n", + "Name: \n", + "Email: email@example.com\n", + "Phone: +1234456666\n", + "Registration Date: 2023-10-12T14:14:04.155+00:00\n", + "Status: Active\n", + "---\n", + "👌 Well done! Your Secret has been remove in production. \n", + "\n", + "None\n" + ] + } + ], "source": [ "for user in users:\n", " print('User Details:')\n", @@ -344,7 +469,12 @@ " print(f'Phone: {user[\"phone\"]}')\n", " print(f'Registration Date: {user[\"registration\"]}')\n", " print(f'Status: {\"Active\" if user[\"status\"] else \"Inactive\"}')\n", - " print('---')" + " print('---')\n", + "#you can also remove all the keys like so :\n", + "naas.secret.delete(name=\"key\")\n", + "naas.secret.delete(name=\"project\")\n", + "naas.secret.delete(name=\"key\")\n", + "print(naas.secret.get(name=\"key\"))#this will give None" ] }, {