javascript axios oauth2 example#oauth2
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript axios oauth2 example#oauth2相关的知识,希望对你有一定的参考价值。
import axios from 'axios'
const clientID = '945510672914-k8ci5ktg4fn71oh03ru7kihqbirtoks5.apps.googleusercontent.com'
const clientSecret = 'Zy3mzlvL5tcxE98X6oWFbDpE'
let instance = axios.create({
headers: { "content-type": "application/x-www-form-urlencoded", "Cache-Control": "no-cache", },
withCredentials: true,
crossdomain: true
})
let data = {
code: code,
client_id: clientID,
client_secret: clientSecret,
redirect_uri: 'http:localhost:8020/auth',
grant_type: 'authorization_code'
}
let str = "";
for (var key in data) {
if (str != "") {
str += "&";
}
str += key + "=" + encodeURIComponent(data[key]);
}
instance.post('https:www.googleapis.com/oauth2/v4/token', str).then(response => {
this.data = response.data
}).catch(err => {
console.log(err)
})
以上是关于javascript axios oauth2 example#oauth2的主要内容,如果未能解决你的问题,请参考以下文章
Spring Boot 和 OAuth2 CORS
Spring Boot 和 OAuth2 CORS
如何在 Javascript 中实现安全的 OAuth2 消费?
使用 OAuth2 下载 Javascript 文件
如何使用 Oauth2 和 javascript 客户端(Spring Oauth2 + Angularjs)实现长期登录会话
来自客户端 javascript 的错误 400 Cognito /oauth2/token 端点