示例#1
0
文件: twitter.py 项目: kylewm/bridgy
  def new(handler, auth_entity=None, **kwargs):
    """Creates and returns a Twitter entity.

    Args:
      handler: the current RequestHandler
      auth_entity: oauth-dropins.twitter.TwitterAuth
      kwargs: property values
    """
    user = json.loads(auth_entity.user_json)
    gr_source = gr_twitter.Twitter(*auth_entity.access_token())
    actor = gr_source.user_to_actor(user)
    return Twitter(id=user['screen_name'],
                   auth_entity=auth_entity.key,
                   url=actor.get('url'),
                   name=actor.get('displayName'),
                   picture=actor.get('image', {}).get('url'),
                   **kwargs)
示例#2
0
文件: twitter.py 项目: mblaney/bridgy
    def new(handler, auth_entity=None, **kwargs):
        """Creates and returns a :class:`Twitter` entity.

    Args:
      handler: the current :class:`webapp2.RequestHandler`
      auth_entity: :class:`oauth_dropins.twitter.TwitterAuth`
      kwargs: property values
    """
        user = json.loads(auth_entity.user_json)
        gr_source = gr_twitter.Twitter(*auth_entity.access_token())
        actor = gr_source.user_to_actor(user)
        return Twitter(id=user['screen_name'],
                       auth_entity=auth_entity.key,
                       url=actor.get('url'),
                       name=actor.get('displayName'),
                       picture=actor.get('image', {}).get('url'),
                       **kwargs)
示例#3
0
  def new(handler, auth_entity=None, **kwargs):
    """Creates and returns a FacebookPage for the logged in user.

    Args:
      handler: the current RequestHandler
      auth_entity: oauth_dropins.facebook.FacebookAuth
      kwargs: property values
    """
    user = json.loads(auth_entity.user_json)
    gr_source = gr_facebook.Facebook(auth_entity.access_token())
    actor = gr_source.user_to_actor(user)
    return FacebookPage(id=user['id'],
                        auth_entity=auth_entity.key,
                        name=actor.get('displayName'),
                        username=actor.get('username'),
                        picture=actor.get('image', {}).get('url'),
                        url=actor.get('url'),
                        **kwargs)
示例#4
0
文件: twitter.py 项目: snarfed/bridgy
  def new(auth_entity=None, **kwargs):
    """Creates and returns a :class:`Twitter` entity.

    Args:
      auth_entity: :class:`oauth_dropins.twitter.TwitterAuth`
      kwargs: property values
    """
    assert 'username' not in kwargs
    assert 'id' not in kwargs
    user = json_loads(auth_entity.user_json)
    gr_source = gr_twitter.Twitter(*auth_entity.access_token())
    actor = gr_source.user_to_actor(user)
    return Twitter(username=user['screen_name'],
                   auth_entity=auth_entity.key,
                   url=actor.get('url'),
                   name=actor.get('displayName'),
                   picture=actor.get('image', {}).get('url'),
                   **kwargs)
示例#5
0
文件: facebook.py 项目: v1cker/bridgy
  def new(handler, auth_entity=None, **kwargs):
    """Creates and returns a :class:`FacebookPage` for the logged in user.

    Args:
      handler: the current :class:`webapp2.RequestHandler`
      auth_entity: :class:`oauth_dropins.facebook.FacebookAuth`
      kwargs: property values
    """
    user = json.loads(auth_entity.user_json)
    gr_source = gr_facebook.Facebook(access_token=auth_entity.access_token())
    actor = gr_source.user_to_actor(user)
    return FacebookPage(id=user['id'],
                        auth_entity=auth_entity.key,
                        name=actor.get('displayName'),
                        username=actor.get('username'),
                        picture=actor.get('image', {}).get('url'),
                        url=actor.get('url'),
                        **kwargs)
示例#6
0
    def new(handler, auth_entity=None, **kwargs):
        """Creates and returns a :class:`GitHub` for the logged in user.

    Args:
      handler: the current :class:`webapp2.RequestHandler`
      auth_entity: :class:`oauth_dropins.github.GitHubAuth`
      kwargs: property values
    """
        user = json.loads(auth_entity.user_json)
        gr_source = gr_github.GitHub(access_token=auth_entity.access_token())
        actor = gr_source.user_to_actor(user)

        # temporary!
        util.email_me(subject='New Bridgy GitHub user!',
                      body=json.dumps(auth_entity.user_json, indent=2))

        return GitHub(id=auth_entity.key.id(),
                      auth_entity=auth_entity.key,
                      name=actor.get('displayName'),
                      picture=actor.get('image', {}).get('url'),
                      url=actor.get('url'),
                      **kwargs)