• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

mchesler613/OAuth2-Integration-with-OAuthlib-and-GitHub: A sample Django app to ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

mchesler613/OAuth2-Integration-with-OAuthlib-and-GitHub

开源软件地址:

https://github.com/mchesler613/OAuth2-Integration-with-OAuthlib-and-GitHub

开源编程语言:

Python 71.6%

开源软件介绍:

auth

This is a sample Django app to authenticate with GitHub as a third-party OAuth2 provider.

Deployment

This app is deployed on AWS running SSL here. This app contains a secret page whose secret content can only be viewed after authenticating with GitHub.

Before authentication, the secret page looks like this:

Before Authentication

After authentication:

After Authentication

Dependencies

This app uses the following Python packages

  • python-dotenv, to store sensitive information
  • oauthlib, to integrate with third-party OAuth2 providers, such as GitHub
  • requests, to send HTTP GET and POST requests

Other requirements include:

  • a GitHub account to login
  • a GitHub OAuth developer account to generic credentials such as client id and client secret.
  • an SSL connection to implement a client callback with a URL endpoint that receives communication back from GitHub's OAuth service.

Why I wrote this app?

  • I wanted to understand and learn how to integrate with a third-party OAuth2 provider by writing some code myself, instead of plugging in a third-party Django app
  • With oauthlib, I am able to write a client service that completes the OAuth2 flow between the client and provider, which requires these steps:
    • request authorization from GitHub at an authorized GitHub URL with client id and state information and expecting a code back
    • receive a code back from GitHub with the prior state information at the client's callback URL
    • fetch a token from GitHub's token URL passing client secret and code as arguments
    • retrieve the authorized user profile data from GitHub as JSON data
    • create a Django User account or reuse an existing authorized User account
    • login to Django with User account
    • proceed with Django app logic based on User privileges

To learn more about GitHub's OAuth2 flow, refer to this doc.

I wrote a supporting article for this project here. If you found any bugs, or would like me to improve this article, please don't hesitate to contact me. Thanks.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
akeneo/api-php-client-ee: Old PHP client of Akeneo PIM EE API. Moved to https:// ...发布时间:2022-06-13
下一篇:
AykutSarac/github-rater: 发布时间:2022-06-13
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap