Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

autodesk forge - Why is Viewer' getViewerToken getting called infinite times?

The function getViewerToken is called infinitely since today without any code change. Is this bug on our side or a bug in the forge viewer?

        iframe.viewer = new iframe.Autodesk.Viewing.GuiViewer3D(iframe.viewerDiv, { extensions: extensions });
        let options = {
            // 'env': 'AutodeskProduction',
            'env': 'MD20ProdEU', //svf2
            'api': 'D3S', //svf2
            'getAccessToken': function(onTokenReady) {
                     ...
            };
  .....

question from:https://stackoverflow.com/questions/65952570/why-is-viewer-getviewertoken-getting-called-infinite-times

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The viewer calls the getAccessToken function whenever the token needs to be refreshed. When you're calling the callback function inside getAccessToken, make sure that the second parameter (expiration time of the new token in seconds) is a positive integer number. Perhaps your code is passing in zero or a negative number, forcing the viewer to repeatedly ask for new tokens.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.7k users

...