【问题标题】:simple Forge 3-legged Oauth with node.js使用 node.js 的简单 Forge 3-legged Oauth
【发布时间】:2021-07-24 08:30:52
【问题描述】:

我是 Forge 的新手,并且正在使用 node.js - 我在让一个简单的 3-legged Oauth 进程正常工作时遇到了一些困难。

这就是我在下面的距离。它给了我错误“无法获取/api/forge/oauth/callback”

我已检查我的回调 url 是否与 Forge 应用程序中的内容匹配。

我最终想要实现的是,获取 Fusion 团队中新创建文件的共享链接,或者至少打开浏览器到文件概览页面。

有人可以帮忙吗?

var express = require('express');
var ForgeSDK = require('forge-apis');
const { stringify } = require('node:querystring');
var opn = require('opn'); 

// Set up Express web server
var app = express();

// Set the Forge Variables
var FORGE_CLIENT_ID = 'client-id', FORGE_CLIENT_SECRET = 'client-secret', REDIRECT_URL = 'http://localhost:3000/api/forge/oauth/callback';

// This is for web server to start listening to port 3000
app.set('port', 3000);
var server = app.listen(app.get('port'), function () {
    console.log('Server listening on port ' + server.address().port);
});

// Initialize the 3-legged OAuth2 client, set specific scopes and optionally set the `autoRefresh` parameter to true
// if you want the token to auto refresh
var autoRefresh = true;
var oAuth2ThreeLegged = new ForgeSDK.AuthClientThreeLegged(FORGE_CLIENT_ID, FORGE_CLIENT_SECRET, REDIRECT_URL, [
    'data:read',
    'data:write'
], autoRefresh);

// Generate a URL page that asks for permissions for the specified scopes.
var AuthURL = oAuth2ThreeLegged.generateAuthUrl();
    console.log(AuthURL)

opn('https://developer.api.autodesk.com/authentication/v1/authorize?response_type=code&client_id=<<client-id>>&redirect_uri=http://localhost:3000/api/forge/oauth/callback&scope=data:read+data:write&state=undefined', {app: 'chrome'}) 

【问题讨论】:

    标签: autodesk-forge


    【解决方案1】:

    您的代码中的回调 API 在哪里?

    BTW 3-Legged oauth 在 nodejs 中实现,您可以将其用作参考: https://learnforge.autodesk.io/#/oauth/3legged/nodejs

    【讨论】:

      【解决方案2】:

      我花了很多时间查看您发布的示例。 当我运行它时,调试控制台显示“服务器正在侦听端口 3000”,当我加载回调 url 时,它给出范围错误,当我加载 localhost:3000 时,它显示“无法获取 /”

      【讨论】:

        猜你喜欢
        • 2014-11-04
        • 2012-12-13
        • 1970-01-01
        • 2017-08-06
        • 2021-05-20
        • 2011-07-30
        • 1970-01-01
        • 2013-08-21
        • 1970-01-01
        相关资源
        最近更新 更多