node.js - 使用 nodejs 获取重定向数据
问题描述
所以我正在使用node-myanimelist npm 包,它是myanimelist API的包装器,并且该包使用pcke-challenge提供挑战(基本上用户转到一个 url,授权并使用访问令牌重定向用户以供我使用)。这是下面的图片来清除这个想法
单击允许后,用户将被重定向到您使用访问令牌指定的 URL。但是这里有一个问题,我的应用程序没有网站,也没有将用户重定向到的地方,那么当用户点击允许时仍然获得令牌的最佳方法是什么?
编辑:
这是代码:
const { Mal, Jikan } = require('node-myanimelist');
const auth = Mal.auth(/* app_id */);
const pkceChallenge = require("pkce-challenge");
const pkce = pkceChallenge();
// This is the URL the user gets
const url = auth.getOAuthUrl(pkce.code_challenge);
// "code" here is what clicking allow on the URL above ^ returns with the redirect
const acount = await auth.authorizeWithCode(code,pkce.code_challenge);
// From then on I can do stuff like `account.anime.search(/* stuff */)`
解决方案
推荐阅读
- apache-kafka - 连接器在 KSQLDB 和 Kafka 中如何工作?
- python-3.x - 某些条件下的密码和用户名验证
- zsh - 重置提示后,命令行自动跳转到下一行
- c - C中的标称类型检查
- javascript - 如果javascript中的href为空,如何禁用锚标记
- python - 数据框中条形图形式值的颜色?
- laravel - 在 laravel 门中总是返回 false
- powerbi - PowerBI Premium 连接服务器分析服务
- erlang - 函数列表中的异常错误:foldl/3(lists.erl,第 1263 行)
- javascript - 如何从 Rust 函数获取字节到 JavaScript?