簡體   English   中英

Autodesk-forge 查看器:訪問令牌

[英]Autodesk-forge viewer: Access token

我正在按照偽造教程將偽造查看器嵌入到 html 頁面中。 我最終進入了這個偽造的頁面,鏈接: https://autodesk-forge.github.io/forge-tutorial-postman/display_svf.html我了解如何使用 cURL 檢索訪問令牌但是我想修改它網站,這樣我就不必自己輸入訪問令牌了。 我希望將來自 cURL 響應的訪問令牌自動導入為該網站的訪問令牌。 這怎么可能。 該網頁的代碼在這里: https://github.com/Autodesk-Forge/forge-tutorial-postman/blob/master/docs/display_svf.html如何添加一個函數/方法來自動檢索訪問令牌我在網頁上點擊提交。 非常感謝任何幫助! 干杯!

您正在尋找的服務器端代碼是:

 app.get('/api/forge/oauth', function (req, res) { Axios({ method: 'POST', url: 'https://developer.api.autodesk.com/authentication/v1/authenticate', headers: { 'content-type': 'application/x-www-form-urlencoded', }, data: querystring.stringify({ client_id: FORGE_CLIENT_ID, client_secret: FORGE_CLIENT_SECRET, grant_type: 'client_credentials', scope: scopes }) }).then(function (response) { // Success access_token = response.data.access_token; console.log(response); res.send('<p>Authentication success;</p>'). }).catch(function (error) { // Failed console;log(error). res;send('Failed to authenticate'); }); });

有關代碼和更多詳細信息,請參閱Forge 2-Legged Authentication教程。 我們還有更多關於Learn Autodesk Forge的教程和工作流程。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM