英文:
How to use API token to access SmartsheetGov by Smartsheet API Python
问题
I am wondering if you could provide your solution on how to connect my agency's SmartsheetGov by using Smartsheet API with Python. I have tried to connect to our agency's SmartsheetGov by Smartsheet API with Python. However, all I got is the response of the invalid token (You could tell the message below) after revoking and creating new tokens.
I tried to follow the instruction in the link below and got my API token value ('FwCw……') by the steps 1 and 2.
Then, I installed the Python SDK by the Smartsheet Python SDK. The Python script below was used to connect our SmartsheetGov.
import os
import smartsheet
os.environ['SMARTSHEET_ACCESS_TOKEN'] = "FwCw...." (The incomplete value of the token here was for security)
smartsheet_client = smartsheet.Smartsheet()
sheetID = 7012956985038964
sheet = smartsheet_client.Sheets.get_sheet(sheetID)
print(sheet)
However, I got the error message below:
{ "response": { "statusCode": 401, "reason": "Unauthorized", "content": { "errorCode": 1002, "message": "Your Access Token is invalid.", "refId": "367b8x" } } }
{ "result": { "code": 1002, "errorCode": 1002, "message": "Your Access Token is invalid.", "name": "ApiError", "recommendation": "Do not retry without fixing the problem.", "refId": "367b8x", "shouldRetry": false, "statusCode": 401 }}
英文:
I am wondering if you could provide your solution on how to connect my agency's SmartsheetGov by using Smartsheet API with python. I have tried to connect to our agency's SmartsheetGov by Smartsheet API with Python. However all I got is the response of the invalid token (You could tell the message below) after revoking and creating new tokens.
I tried to follow the instruction in the link below and got my API token value (‘FwCw……’) by the steps 1 and 2.
Then, I installed the python SDK by the Smartsheet Python SDK. The python script below was used to connect our SmartsheetGov.
import os
import smartsheet
os.environ['SMARTSHEET_ACCESS_TOKEN'] = "FwCw...."(The incomplete value of token here was for the security)
smartsheet_client = smartsheet.Smartsheet()
sheetID = 7012956985038964
sheet = smartsheet_client.Sheets.get_sheet(sheetID)
print(sheet)
However, I got the error message below:
{"response": {"statusCode": 401, "reason": "Unauthorized", "content": {"errorCode": 1002, "message": "Your Access Token is invalid.", "refId": "367b8x"}}}
{"result": {"code": 1002, "errorCode": 1002, "message": "Your Access Token is invalid.", "name": "ApiError", "recommendation": "Do not retry without fixing the problem. ", "refId": "367b8x", "shouldRetry": false, "statusCode": 401}}
答案1
得分: 2
client = smartsheet.Smartsheet(api_base=smartsheet.gov_base)
英文:
client = smartsheet.Smartsheet(api_base=smartsheet.__gov_base__)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论