簡體   English   中英

Autodesk Forge Viewer:在另一個應用程序中使用從一個應用程序翻譯的 urn?

[英]Autodesk Forge Viewer : Using translated urn from one application in another application?

I have an Angular Application, and I was trying to integrate Autodesk Forge Viewer into my Application, for that first I created a Sample Application following the URL ( https://learnforge.autodesk.io/#/tutorials/viewmodels ) and I was能夠在 Forge 查看器中查看繪圖,然后在將 Forge 查看器集成到我的應用程序時檢查可行性,我按照以下步驟操作:

以下是我從示例應用程序中獲得的翻譯后的骨灰盒:“dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6eXlpYnFqdW8yeW9yNTF2c2d2Y3VzcHlnbnk5amVhbnQtdmxmbTIyL0RDLUhRLTAxQVIlMjAoMTMpLmR3Zw”所以我在我的應用程序中使用了這個特定的骨灰盒,代碼也用於查看下面的繪圖:

var contextObj = this;
    var urn = "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6eXlpYnFqdW8yeW9yNTF2c2d2Y3VzcHlnbnk5amVhbnQtdmxmbTIyL0RDLUhRLTAxQVIlMjAoMTMpLmR3Zw";
    this.objiWhiz.Token(function (resCallback) {
    contextObj.token = resCallback;
     var access_token = contextObj.token;
     jQuery.ajax({
         url: 'https://developer.api.autodesk.com/modelderivative/v2/designdata/' + urn + '/manifest',
         headers: { 'Authorization': 'Bearer ' + access_token },
         success: function (res) {
          if (res.status === 'success')
                    this.launchViewer(urn);
                 },
          error: function (err) {
                 console.log("not sucessfull");
                 }
        });
// using the Token Function I was able to get the access_token,

this.Token = function (resCallback) {
   try {
       var that = this;
       var data = "12";   //   ViewablesRead = 12
       $.ajax({
           url:  '/6.8/api/iWhiz/Get2LeggedTokenAsync',
           type: "POST",
           headers: {  "__RequestVerificationToken": that.m_csrfToken },
          data: JSON.stringify([data]),
          contentType: 'application/json; charset=utf-8',
          success: function (returnObject) {
               resCallback(returnObject.access_token);                 
               }
         });
   }

   catch (e) {
       resCallback(9);
   }
 },
public async Task<dynamic> Get2LeggedTokenAsync(List<string> Val)

   {

       TwoLeggedApi oauth = new TwoLeggedApi();

       string grantType = "client_credentials";

       dynamic bearer = await oauth.AuthenticateAsync(

        "FORGE_CLIENT_ID","FORGE_CLIENT_SECRET"

         grantType,

         new Scope[] { Scope.DataWrite });

       return bearer;
}

GET https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6eXlpYnFqdW8yeW9yNTF2c2d2Y3VzcHlnbnk5amVhbnQtdmxmbTIyL0RDLUhRLTAxQVIlMjAoMTMpLmR3Zw/manifest 403 (Forbidden)

and when I click the URL: https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6eXlpYnFqdW8yeW9yNTF2c2d2Y3VzcHlnbnk5amVhbnQtdmxmbTIyL0RDLUhRLTAxQVIlMjAoMTMpLmR3Zw/manifest

我收到消息:{“developerMessage”:“請求中未提供令牌。”,“moreInfo”:“https://forge.autodesk.com/en/docs/oauth/v2/developers_guide/error_handling/” , "errorCode": "AUTH-010"}

您在請求訪問令牌時指定的 scope 是data:write only,這是不正確的。 要訪問翻譯后的結果,您需要data:readviewables:read 請參閱https://forge.autodesk.com/en/docs/model-derivative/v2/reference/http/manifest/urn-manifest-GET/

public async Task<dynamic> Get2LeggedTokenAsync(List<string> Val)
 
       {
 
           TwoLeggedApi oauth = new TwoLeggedApi();
 
           string grantType = "client_credentials";
 
           dynamic bearer = await oauth.AuthenticateAsync(
 
            "FORGE_CLIENT_ID","FORGE_CLIENT_SECRET"
 
             grantType,
 
             new Scope[] { Scope.ViewablesRead });
             // new Scope[] { Scope.DataRead });
 
           return bearer;
}

暫無
暫無

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

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