我需要从URL中获取授权代码。它以查询字符串参数的形式出现。
当我运行以下URL时
https://XXX.authenticaion.com/oauth/authorize?response_type=code&client_id=sb!t113
它重定向到http://localhost:8080/?code=8wFgU1GJo3
我需要解析localhost URL并获取代码。
关于如何检索代码,请帮助
代码:
const url = 'https://XXX.authenticaion.com/oauth/authorize?response_type=code&client_id=sb!t113'
const config = {
method: "GET"
};
const response = await fetch(url ,config);
console.log('Response Text...............'+response.text())发布于 2020-03-15 09:27:28
您可以使用普通的js URL web来创建code对象,然后获取code值。
const url = 'http://localhost:8080/?code=8wFgU1GJo3'
const code = new URL(url).searchParams.getAll('code')
console.log(code)
https://stackoverflow.com/questions/60691286
复制相似问题