views.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:mirandum 作者: google 项目源码 文件源码
def auth_return(request):
  if not xsrfutil.validate_token(settings.SECRET_KEY, str(request.GET['state']),
                                 request.user.username):
    return  HttpResponseBadRequest()
  credential = FLOW.step2_exchange(request.GET)
  http = httplib2.Http()
  http = credential.authorize(http)
  resp, data = http.request("https://beam.pro/api/v1/users/current")
  data = json.loads(data)
  print data
  channelId = None
  if 'channel' in data:
    channelId = data['channel']['id']
  name = data['channel'].get("name") or "(unnamed)"
  internal_label = "%s-%s" % (channelId, name)
  ac = BeamAppCreds(user=request.user, label=internal_label)
  ac.save()
  storage = Storage(BeamCredentialsModel, 'id', ac, 'credential')
  storage.put(credential)
  pu = BeamUpdate(credentials=ac, user=request.user, type="beam")
  pu.save()
  return HttpResponseRedirect("/beam/")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号