From 69fbab9323639a883bc11537988a2ef3966f9f6e Mon Sep 17 00:00:00 2001 From: Chuong Ho Date: Mon, 6 May 2024 15:21:57 +0800 Subject: [PATCH] Update 01. Setup And Authentication.ipynb --- .../01. Setup And Authentication.ipynb | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/APSToolkitPython/Tutorials/01. Setup And Authentication.ipynb b/APSToolkitPython/Tutorials/01. Setup And Authentication.ipynb index cface1a..39611b6 100644 --- a/APSToolkitPython/Tutorials/01. Setup And Authentication.ipynb +++ b/APSToolkitPython/Tutorials/01. Setup And Authentication.ipynb @@ -428,6 +428,46 @@ "source": [ "Congratulations! You've successfully obtained a 2-legged token from Autodesk Forge. You can now use this token to authenticate requests to Autodesk Forge services, such as the Data Management API or the Model Derivative API." ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Get User Information\n", + "To get the user information logged in, you need to make sure that you used the 3-legged token to get the user information." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from aps_toolkit import Auth\n", + "redirect_uri = \"http://localhost:8080/api/auth/callback\"\n", + "scopes = 'data:read viewables:read'\n", + "token = auth.auth3leg(redirect_uri, scopes)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "User: Ho Van Chuong\n", + "Job Title: Computational Design Researcher\n" + ] + } + ], + "source": [ + "user_infor = auth.get_user_info()\n", + "print(\"User:\",user_infor[\"name\"])\n", + "print(\"Job Title:\",user_infor[\"job_title\"])" + ] } ], "metadata": {