调用github API使用github OauthAPP实现网站授权登录功能

  1. Request a user’s GitHub identity(请求一个github用户的id)
    GET https://github.com/login/oauth/authorize
    When your GitHub App specifies a login parameter, it prompts users with a specific account they can use for signing in and authorizing your app.
Parameters(参数)

在这里插入图片描述

state:防止跨站点攻击
allow_signup:此参数可选填
  1. Users are redirected back to your site by GitHub(用户被github重定向到你的站点)
    If the user accepts your request, GitHub redirects back to your site with a temporary code in a code parameter as well as the state you provided in the previous step in a state parameter. The temporary code will expire after 10 minutes. If the states don’t match, then a third party created the request, and you should abort the process.

Exchange this code for an access token:

POST https://github.com/login/oauth/access_token
Response
By default, the response takes the following form:

access_token=e72e16c7e42f292c6912e7710c838347ae178b4a&token_type=bearer
3. Use the access token to access the API
The access token allows you to make requests to the API on a behalf of a user.

Authorization: token OAUTH-TOKEN
GET https://api.github.com/user
For example, in curl you can set the Authorization header like this:

curl -H “Authorization: token OAUTH-TOKEN” https://api.github.com/user

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值