如何使用 API 令牌访问 SmartsheetGov 通过 Smartsheet API Python

huangapple go评论66阅读模式
英文:

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.

如何使用 API 令牌访问 SmartsheetGov 通过 Smartsheet API Python

如何使用 API 令牌访问 SmartsheetGov 通过 Smartsheet API Python

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.

如何使用 API 令牌访问 SmartsheetGov 通过 Smartsheet API Python

如何使用 API 令牌访问 SmartsheetGov 通过 Smartsheet API Python

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)

参考链接: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/ADVANCED.md#working-with-smartsheetgovcom-accounts

英文:
client = smartsheet.Smartsheet(api_base=smartsheet.__gov_base__)

reference: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/ADVANCED.md#working-with-smartsheetgovcom-accounts

huangapple
  • 本文由 发表于 2023年3月31日 03:38:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/75892322.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定