帮助从社交应用程序获取用户信息的python包
social-user-info的Python项目详细描述
社交用户信息
帮助从社交应用程序获取用户信息的python包
安装
Required Python Version >= 3
pip install social-user-info
支持的社交媒体
- 谷歌
- Github
它是怎么工作的?
包有一个方法APIService.get_user_info(access_token, auth_source)
。
此方法接受访问令牌和身份验证源,并返回与给定访问令牌对应的用户信息
测试
获取您的Google访问令牌:
- 导航到:https://developers.google.com/oauthplayground/
- 在步骤1中,选择google oauth2 api v2并添加
https://www.googleapis.com/auth/userinfo.email
和https://www.googleapis.com/auth/userinfo.profile
。单击“授权API” - 登录/选择您想要访问令牌的帐户
- 在步骤2中,单击exchange authorization code for tokens
- 从返回的json中获取
access_token
获取Facebook访问令牌
获取GitHub访问令牌
- 登录您的github帐户
- 导航到“设置”
- 导航到左下角的“开发人员设置”
- 导航到个人访问令牌
- 生成新标记
- 点击generate token获取
access_token
获取用户信息
fromsocial_user_info.social_user_infoimportAPIServiceAPIService.get_user_info(access_token={access_token_from_above_step},auth_source='google')APIService.get_user_info(access_token={access_token_obtained_from_facebook},auth_source='facebook')APIService.get_user_info(access_token={access_token_obtained_from_github},auth_source='github')
access_token
fromsocial_user_info.social_user_infoimportAPIServiceAPIService.get_user_info(access_token={access_token_from_above_step},auth_source='google')APIService.get_user_info(access_token={access_token_obtained_from_facebook},auth_source='facebook')APIService.get_user_info(access_token={access_token_obtained_from_github},auth_source='github')