How to use access_token? (api.smartsheet.com/2.0/token)

Bortyk
Bortyk
edited 07/05/23 inAPI & Developers

Node.js

How to use access_token?

I'm making a request:


axios.post('https://api.smartsheet.com/2.0/token')...


response:

{

access_token: 'xxx',

token_type: 'bearer',

refresh_token: 'xxx',

expires_in: 604799

}


var smartsheet = client.createClient({

accessToken: 'xxx',

logLevel: 'info',

});


But the result is always the same:

statusCode: 403,

errorCode: 1004,

message: 'You are not authorized to perform this action.',

refId: 'cdx056'


Why is that? Why is the access Token incorrect?

Best Answer

  • Genevieve P.
    Genevieve P. Employee Admin
    Answer ✓

    Hey@Bortyk

    An Access Token will only provide you with the same permissions and access that the account has in the Smartsheet UI.

    For example, if you're trying to Edit a sheet through the API, you'll need to have at least Editor permissions on that sheet in the UI.

    I would suggest making sure that the account you're using to access the API has the correct permissions on each item and also in the account as well (e.g. if it needs to be a System Admin for the plan or not).

    Cheers,

    Genevieve

Answers

  • All I've realized now is that this token doesn't have enough access rights to make requests. All I managed to do was get data about myself using the smartsheet_client code

    .Users.get_current_user()

    How do I get more rights? How exactly should this be prescribed and where?

  • Hamza1
    Hamza1 Moderator

    Hi@Bortyk,

    The error message you're getting usually occurs when the Authentication header is set incorrectly- the bearer may not have been added to the header value or there isn’t a space between Bearer and the access token.

    More information on this is outlined in the following Smartsheet API documentations:

    To generate a new access token:

    • On the left Navigation Bar, select Account.
    • Select Apps & Integrations.
    • In the Personal Settings form, select API Access.
    • 在API访问选项卡中,年代elect Generate new access token.
    • You can also revoke existing tokens in this tab.

    More information on this is outlined in the Help articlehere. Additionally, there is acommunity of developersthat can be a great resource for troubleshooting issues regarding your use case.


    Thanks,

    Hamza

  • All I've realized now is that this token doesn't have enough access rights to make requests. All I managed to do was get data about myself using the smartsheet_client code

    .Users.get_current_user()

    How do I get more rights? How exactly shosduld this be prescribed and where?



    Need use SCOPE

    app.get('/auth2', (req, res) => { const authUrl = 'https://app.smartsheet.com/b/authorize'; const params = { response_type: 'code', client_id: 'xxxxxxxx', // CLIENT_ID scope: 'ADMIN_SHEETS ADMIN_USERS READ_SHEETS READ_USERS READ_CONTACTS WRITE_SHEETS' }; const url = authUrl + '?' + new URLSearchParams(params); res.redirect(url) });


  • Genevieve P.
    Genevieve P. Employee Admin
    Answer ✓

    Hey@Bortyk

    An Access Token will only provide you with the same permissions and access that the account has in the Smartsheet UI.

    For example, if you're trying to Edit a sheet through the API, you'll need to have at least Editor permissions on that sheet in the UI.

    I would suggest making sure that the account you're using to access the API has the correct permissions on each item and also in the account as well (e.g. if it needs to be a System Admin for the plan or not).

    Cheers,

    Genevieve

Widgets { get { return widgets; } set { widgets = value; } } When you update the Sight you get a JSON error. The API documentation states Update is for a dashboard name change - this does work ok. Can anyone confirm whether you can or cannot update…","snippet":"The sight object exposes Widgets as a get and a set. public IList Widgets { get { return widgets; } set { widgets = value; } } When you update the Sight you get a JSON…","categoryID":320,"dateInserted":"2023-08-23T16:10:13+00:00","dateUpdated":null,"dateLastComment":"2023-08-25T02:50:25+00:00","insertUserID":136172,"insertUser":{"userID":136172,"name":"BKing","title":"","url":"https:\/\/community.smartsheet.com\/profile\/BKing","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-08-25T14:24:11+00:00","banned":0,"punished":0,"private":false,"label":"✭✭"},"updateUserID":null,"lastUserID":139601,"lastUser":{"userID":139601,"name":"jmyzk_cloudsmart_jp","title":"jmyzk","url":"https:\/\/community.smartsheet.com\/profile\/jmyzk_cloudsmart_jp","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/ZBVD3K8PY0D5\/n7CZ1F4XWEM9Y.JPG","dateLastActive":"2023-08-26T12:59:37+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":3,"countViews":45,"score":null,"hot":3385740638,"url":"https:\/\/community.smartsheet.com\/discussion\/109346\/can-anyone-help-with-the-dashboard-api","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/109346\/can-anyone-help-with-the-dashboard-api","format":"Rich","lastPost":{"discussionID":109346,"commentID":392512,"name":"Re: Can anyone help with the Dashboard api?","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/392512#Comment_392512","dateInserted":"2023-08-25T02:50:25+00:00","insertUserID":139601,"insertUser":{"userID":139601,"name":"jmyzk_cloudsmart_jp","title":"jmyzk","url":"https:\/\/community.smartsheet.com\/profile\/jmyzk_cloudsmart_jp","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/ZBVD3K8PY0D5\/n7CZ1F4XWEM9Y.JPG","dateLastActive":"2023-08-26T12:59:37+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"API & Developers","url":"https:\/\/community.smartsheet.com\/categories\/api-developers"}],"groupID":null,"statusID":3,"attributes":{"question":{"status":"accepted","dateAccepted":"2023-08-24T07:38:40+00:00","dateAnswered":"2023-08-24T00:17:46+00:00","acceptedAnswers":[{"commentID":392255,"body":"

@BKing<\/a> <\/p>

\n \n https:\/\/stackoverflow.com\/questions\/56711545\/is-it-possible-to-change-widget-data-of-dashboards-through-the-smartsheet-api\n <\/a>\n<\/div>


<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":320,"name":"API & Developers","url":"https:\/\/community.smartsheet.com\/categories\/api-developers","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[]},{"discussionID":109281,"type":"question","name":"Bridge and FedEx Module - Authentication Problem","excerpt":"I'm getting an authentication connect issue when trying to run the FedEx Module step in my Bridge job flow. I set up a FedEx Developer Account and created a test new project. When I run the Bridge job I get an error on on the Module run saying, \"failed to execute extension module : Authentication Failed\". I mapped the…","snippet":"I'm getting an authentication connect issue when trying to run the FedEx Module step in my Bridge job flow. I set up a FedEx Developer Account and created a test new project. When…","categoryID":320,"dateInserted":"2023-08-22T16:13:19+00:00","dateUpdated":null,"dateLastComment":"2023-08-25T14:18:51+00:00","insertUserID":148855,"insertUser":{"userID":148855,"name":"cabbsman","url":"https:\/\/community.smartsheet.com\/profile\/cabbsman","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!88cq90f5xTs!8sDpd7uL9Ps!kj4X4avpgGN","dateLastActive":"2023-08-25T14:19:44+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭"},"updateUserID":null,"lastUserID":91566,"lastUser":{"userID":91566,"name":"Genevieve P.","title":"Community Manager","url":"https:\/\/community.smartsheet.com\/profile\/Genevieve%20P.","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/KHY4Y67W0VRX\/nF76D5N9MFB28.png","dateLastActive":"2023-08-25T20:36:29+00:00","banned":0,"punished":0,"private":false,"label":"Employee Admin"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":3,"countViews":53,"score":null,"hot":3385695730,"url":"https:\/\/community.smartsheet.com\/discussion\/109281\/bridge-and-fedex-module-authentication-problem","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/109281\/bridge-and-fedex-module-authentication-problem","format":"Rich","tagIDs":[227,369],"lastPost":{"discussionID":109281,"commentID":392578,"name":"Re: Bridge and FedEx Module - Authentication Problem","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/392578#Comment_392578","dateInserted":"2023-08-25T14:18:51+00:00","insertUserID":91566,"insertUser":{"userID":91566,"name":"Genevieve P.","title":"Community Manager","url":"https:\/\/community.smartsheet.com\/profile\/Genevieve%20P.","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/KHY4Y67W0VRX\/nF76D5N9MFB28.png","dateLastActive":"2023-08-25T20:36:29+00:00","banned":0,"punished":0,"private":false,"label":"Employee Admin"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"API & Developers","url":"https:\/\/community.smartsheet.com\/categories\/api-developers"}],"groupID":null,"statusID":3,"image":{"url":"https:\/\/us.v-cdn.net\/6031209\/uploads\/G9UB21M8QHGL\/screenshot-28125-29.png","urlSrcSet":{"10":"","300":"","800":"","1200":"","1600":""},"alt":"Screenshot (125).png"},"attributes":{"question":{"status":"accepted","dateAccepted":"2023-08-25T14:00:28+00:00","dateAnswered":"2023-08-25T08:23:46+00:00","acceptedAnswers":[{"commentID":392524,"body":"

Hey @cabbsman<\/a> <\/p>

I'm not sure why you're getting the Authentication error, however I don't believe you need to connect to the developer account to track your FedEx parcel! 🙂<\/span><\/p>

Try disconnecting from the developer account and simply click Connect in the Extension:<\/p>

\n
\n \n \"Screenshot<\/img><\/a>\n <\/div>\n<\/div>\n

Hopefully this helps bypass the error. Let me know if that worked for you!<\/p>

Cheers,<\/p>

Genevieve<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":320,"name":"API & Developers","url":"https:\/\/community.smartsheet.com\/categories\/api-developers","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[{"tagID":227,"urlcode":"api-and-developers","name":"API and Developers"},{"tagID":369,"urlcode":"bridge-by-smartsheet","name":"Bridge"}]},{"discussionID":109267,"type":"question","name":"Is there any way to get a sheetID from the KEY retrieved from a sheet access report?","excerpt":"I am a system admin, and we recently had to let go of our other system admin. I am trying to find out what sheets he had access to that I didn't, so I could could access to those sheets. The only way I can compare what I have access to versus was he had access to was a sheet access report, which has a sheet Key, not the…","snippet":"I am a system admin, and we recently had to let go of our other system admin. I am trying to find out what sheets he had access to that I didn't, so I could could access to those…","categoryID":320,"dateInserted":"2023-08-22T15:06:55+00:00","dateUpdated":null,"dateLastComment":"2023-08-23T14:06:57+00:00","insertUserID":137019,"insertUser":{"userID":137019,"name":"Samuel Mueller","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Samuel%20Mueller","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/B9G8B70WXQWC\/nKTI46EH9WQOM.jpg","dateLastActive":"2023-08-25T18:19:58+00:00","banned":0,"punished":0,"private":false,"label":"Overachievers"},"updateUserID":null,"lastUserID":137019,"lastUser":{"userID":137019,"name":"Samuel Mueller","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Samuel%20Mueller","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/B9G8B70WXQWC\/nKTI46EH9WQOM.jpg","dateLastActive":"2023-08-25T18:19:58+00:00","banned":0,"punished":0,"private":false,"label":"Overachievers"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":3,"countViews":40,"score":null,"hot":3385518232,"url":"https:\/\/community.smartsheet.com\/discussion\/109267\/is-there-any-way-to-get-a-sheetid-from-the-key-retrieved-from-a-sheet-access-report","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/109267\/is-there-any-way-to-get-a-sheetid-from-the-key-retrieved-from-a-sheet-access-report","format":"Rich","tagIDs":[227,526],"lastPost":{"discussionID":109267,"commentID":392110,"name":"Re: Is there any way to get a sheetID from the KEY retrieved from a sheet access report?","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/392110#Comment_392110","dateInserted":"2023-08-23T14:06:57+00:00","insertUserID":137019,"insertUser":{"userID":137019,"name":"Samuel Mueller","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Samuel%20Mueller","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/B9G8B70WXQWC\/nKTI46EH9WQOM.jpg","dateLastActive":"2023-08-25T18:19:58+00:00","banned":0,"punished":0,"private":false,"label":"Overachievers"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"API & Developers","url":"https:\/\/community.smartsheet.com\/categories\/api-developers"}],"groupID":null,"statusID":3,"attributes":{"question":{"status":"accepted","dateAccepted":"2023-08-23T14:05:46+00:00","dateAnswered":"2023-08-23T13:36:46+00:00","acceptedAnswers":[{"commentID":392096,"body":"

Hey @Samuel Mueller<\/a> <\/p>

They key is something you can provide to Support to help them find the specific sheet down the line, if needed. For your purposes, it can help identify different sheets when they have the same name. <\/p>

Here's more information:<\/p>

\n \n https:\/\/help.smartsheet.com\/articles\/2482665-sheet-access-report\n <\/a>\n<\/div>

Cheers,<\/p>

Genevieve<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":320,"name":"API & Developers","url":"https:\/\/community.smartsheet.com\/categories\/api-developers","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[{"tagID":227,"urlcode":"api-and-developers","name":"API and Developers"},{"tagID":526,"urlcode":"system-admin","name":"system admin"}]}],"initialPaging":{"nextURL":"https:\/\/community.smartsheet.com\/api\/v2\/discussions?page=2&categoryID=320&includeChildCategories=1&type%5B0%5D=Question&excludeHiddenCategories=1&sort=-hot&limit=3&expand%5B0%5D=all&expand%5B1%5D=-body&expand%5B2%5D=insertUser&expand%5B3%5D=lastUser&status=accepted","prevURL":null,"currentPage":1,"total":216,"limit":3},"title":"Trending in API & Developers","subtitle":null,"description":null,"noCheckboxes":true,"containerOptions":[],"discussionOptions":[]}">

Trending in API & Developers