流程图
前端代码
```javascript
class OauthView(APIView):
def get(self, request):
code = request.query_params.get('code')
print(code)
# 请求数据
request_data = {
'client_id': '1089625992',
'client_secret': '9c99fce9d80de7cb644ca4a1946bf8d6',
'grant_type': 'authorization_code',
'code': code,
'redirect_uri': 'http://127.0.0.1:8080/callback'
}
# 请求地址
request_url = 'https://api.weibo.com/oauth2/access_token'
"""
pip install requests
"""
# requests是爬虫模块,使用post方法,发送请求,获取数据
res = requests.post(url=request_url, data=request_data)
# json(),获取json格式的数据,text, 获取文本 content 获取二进制流
print(res.json())
res_json =