Autodesk 平台服务访问令牌

问题描述 投票:0回答:1

遵循 Autodesk 的 APS 2-legged 身份验证文档,我应该在 APS 教程中为简单查看器调用 POST 令牌端点。

https://github.com/autodesk-platform-services/aps-simple-viewer-nodejs

当前代码产生错误代码 Auth-001,“指定的 client_id 无权访问 api 产品”:

Error Image 1

Error Image 2

错误代码没有意义,我已经仔细检查了我的 client_id,所以问题可能出在其他地方。

上传到 github 上的示例不包含 getAccessToken() 函数上的任何附加代码行,如下面的代码所示。

async function getAccessToken(callback) {
    try {
        const clientId = "<____________________________________________________>"
        const clientSecret = "<________________________________________________>"

        // Base64 encode the client ID and client secret
        const concatword = clientId + ":" + clientSecret;
        const base64word = btoa(concatword);

        const url = 'https://developer.api.autodesk.com/authentication/v2/token';
        const body = new URLSearchParams({
            'grant_type': 'client_credentials',
            'scope': 'data:read'
        });

        const resp = await fetch(url, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
                'Authorization': 'Basic ' + base64word
            },
            body: body
        });

我哪里错了。 github上的代码: https://github.com/retug/APSExamples/tree/main/simpleViewer

oauth autodesk-forge
1个回答
0
投票

您的错误表明您正在尝试访问未经您授权的API。 这与身份验证无关,而是与 API 授权有关。

请查看如何创建应用程序并设置凭据:https://tutorials.autodesk.io/#create-app-credentials

© www.soinside.com 2019 - 2024. All rights reserved.