egg-gitee-d
v1.0.0
Published
- A.标签
Downloads
4
Readme
Gitee
OAuth2 获取 AccessToken 认证步骤
- A.标签
https://gitee.com/oauth/authorize?client_id={client_id}&redirect_uri={redirect_uri}&response_type=code
- B.回调页
async mounted() {
if (this.$route.query.code&&this.$route.query.code!==localStorage.getItem('code')) {
localStorage.setItem('code',this.$route.query.code)
let codeT = await 方法({ id: this.$route.query.code }); //生成
if (codeT.data.code === 1) {
localStorage.setItem();//token csrf id
}
//D.( POST请求 )
let result = await 方法(this.$route.query.code); //传code 生成access_token
let userInfo = await 方法(result.data.access_token); //传 access_token 生成用户信息
console.log(userInfo);
}
}
init/controller/home
async stoken(){
let token = getToken(this.ctx.request.body.id)
this.ctx.body={
code:1,
id:this.ctx.request.body.id,
token,
csrf:this.ctx.csrf,
msg:'登录成功'
}
}