English 中文(简体)
采用应用标准 SDK
原标题:Need Guidance on JWT Validation in Node.js Using Appwrite SDK

在Node.js的后端利用Appwstone SDK寻求帮助。 目前,我们设计了后台,成功地在“彩虹”客户方面实施了“金矿”创建。 然而,在Node.js服务机上,特别是在设立新职位时,面临对《维也纳条约法公约》的验证的挑战。

Currently, our post creation method looks like this:

const { config, attrs, enums } = require( ./config );
const sdk = require("node-appwrite");
const client = new sdk.Client();

client.setEndpoint(config.endpoint);
client.setProject(config.projectId);
client.setKey(config.key);

const databases = new sdk.Databases(client);

const createPost = async (newPost) => {
    return await databases.createDocument(config.databaseId, config.collectionPostsId, sdk.ID.unique(), newPost);
}

现在,我们希望将《维也纳条约法公约》的确认纳入到创建过程中。 员额方法:

const createPost = async (token, newPost) => {
    // Validate the token with the SDK method here
    // ...

    return await databases.createDocument(config.databaseId, config.collectionPostsId, sdk.ID.unique(), newPost);
}

在我们的研究中,我们发现《图瓦卢条约》的文件。 然而,我们正在努力了解如何根据我们的具体设想验证用户。 这些文件显示,《年鉴》的客户是:

const { Client } = require( node-appwrite );

const client = new Client()
    .setEndpoint( https://cloud.appwrite.io/v1 ) // Your API Endpoint
    .setProject( <PROJECT_ID> ) // Your project ID
    .setJWT( eyJJ9.eyJ...886ca ); // Your secret JSON Web Token

我们的混淆在于,像《维也纳条约法公约》这样的用户特定信息被设定为一个特定的申请对象(Client)。 我们愿就如何在我们的设想中适当验证用户的象征提供指导:

const createPost = async (token, newPost) => {
    // Validate the token with the SDK method here
    // ...

    return await databases.createDocument(config.databaseId, config.collectionPostsId, sdk.ID.unique(), newPost);
}

我们赞赏任何能够帮助我们更好地理解和实施《南太地堡条约》验证的见解或密码例子。

事先感谢你的援助!

问题回答

您可使用<代码>账户.get()方法。

In your createPost function, you need an Account object (const account = new Account(client), where client is the Client instance you ve called setJWT() on).

如果《维也纳条约法公约》因任何理由都无效,则要求“<代码>account.get(),则将构成例外。 如果JWTis 有效,它将退还user





相关问题
How to make Sequelize use singular table names

I have an model called User but Sequelize looks for the table USERS whenever I am trying to save in the DB. Does anyone know how to set Sequelize to use singular table names? Thanks.

What is Node.js? [closed]

I don t fully get what Node.js is all about. Maybe it s because I am mainly a web based business application developer. What is it and what is the use of it? My understanding so far is that: The ...

Clientside going serverside with node.js

I`ve been looking for a serverside language for some time, and python got my attention somewhat. But as I already know and love javascript, I now want learn to code on the server with js and node.js. ...

Can I use jQuery with Node.js?

Is it possible to use jQuery selectors/DOM manipulation on the server-side using Node.js?

How do I escape a string for a shell command in node?

In nodejs, the only way to execute external commands is via sys.exec(cmd). I d like to call an external command and give it data via stdin. In nodejs there does yet not appear to be a way to open a ...

热门标签