Skip to content

Instantly share code, notes, and snippets.

@chuongmep
Created September 28, 2022 11:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save chuongmep/c760ad04a45865f6576412f217203c26 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: autodesk_forge_sdk in c:\\users\\chuon\\appdata\\local\\programs\\python\\python310\\lib\\site-packages (0.1.2)\n"
]
}
],
"source": [
"!pip install autodesk_forge_sdk"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"os.environ[\"FORGE_CLIENT_ID\"] = \"xxx\"\n",
"os.environ[\"FORGE_CLIENT_SECRET\"] = \"xxx\"\n"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'type': 'hubs',\n",
" 'id': 'b.ffc5d460-e1a3-4328-a423-e68f2f9854d4',\n",
" 'attributes': {'name': 'Trial account yltqzfqiizmnqxmfpn@kvhrw.com',\n",
" 'extension': {'type': 'hubs:autodesk.bim360:Account',\n",
" 'version': '1.0',\n",
" 'schema': {'href': 'https://developer.api.autodesk.com/schema/v1/versions/hubs:autodesk.bim360:Account-1.0'},\n",
" 'data': {}},\n",
" 'region': 'US'},\n",
" 'links': {'self': {'href': 'https://developer.api.autodesk.com/project/v1/hubs/b.ffc5d460-e1a3-4328-a423-e68f2f9854d4'}},\n",
" 'relationships': {'projects': {'links': {'related': {'href': 'https://developer.api.autodesk.com/project/v1/hubs/b.ffc5d460-e1a3-4328-a423-e68f2f9854d4/projects'}}}}}]"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import os\n",
"from autodesk_forge_sdk import AuthenticationClient, Scope, DataManagementClient,OAuthTokenProvider\n",
"client = DataManagementClient(OAuthTokenProvider(os.environ[\"FORGE_CLIENT_ID\"], os.environ[\"FORGE_CLIENT_SECRET\"]))\n",
"hubs = client.get_all_hubs()\n",
"hubs"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'jsonapi': {'version': '1.0'},\n",
" 'links': {'self': {'href': 'https://developer.api.autodesk.com/project/v1/hubs'}},\n",
" 'data': [{'type': 'hubs',\n",
" 'id': 'b.ffc5d460-e1a3-4328-a423-e68f2f9854d4',\n",
" 'attributes': {'name': 'Trial account yltqzfqiizmnqxmfpn@kvhrw.com',\n",
" 'extension': {'type': 'hubs:autodesk.bim360:Account',\n",
" 'version': '1.0',\n",
" 'schema': {'href': 'https://developer.api.autodesk.com/schema/v1/versions/hubs:autodesk.bim360:Account-1.0'},\n",
" 'data': {}},\n",
" 'region': 'US'},\n",
" 'links': {'self': {'href': 'https://developer.api.autodesk.com/project/v1/hubs/b.ffc5d460-e1a3-4328-a423-e68f2f9854d4'}},\n",
" 'relationships': {'projects': {'links': {'related': {'href': 'https://developer.api.autodesk.com/project/v1/hubs/b.ffc5d460-e1a3-4328-a423-e68f2f9854d4/projects'}}}}}],\n",
" 'meta': {'warnings': [{'Id': None,\n",
" 'HttpStatusCode': '403',\n",
" 'ErrorCode': 'BIM360DM_ERROR',\n",
" 'Title': 'Unable to get hubs from BIM360DM EMEA.',\n",
" 'Detail': \"You don't have permission to access this API\",\n",
" 'AboutLink': None,\n",
" 'Source': None,\n",
" 'meta': None}]}}"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"client.get_hubs()"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'https://developer.api.autodesk.com/project/v1'"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"client.base_url"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.0 64-bit",
"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.10.0"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "ec8507a9d0d51557069ff9e910ec47822a40c04209a5f1a2da16428a37fdf4db"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment