Ejemplo n.º 1
0
def create_account(db_session, email_address, response):
    try:
        account = db_session.query(OutlookAccount).filter_by(
            email_address=email_address).one()
    except sqlalchemy.orm.exc.NoResultFound:
        namespace = Namespace()
        account = OutlookAccount(namespace=namespace)

    account.refresh_token = response['refresh_token']
    account.date = datetime.datetime.utcnow()
    tok = response.get('access_token')
    expires_in = response.get('expires_in')
    account.set_access_token(tok, expires_in)
    account.scope = response.get('scope')
    account.email_address = response.get('emails')['account']
    account.o_id_token = response.get('user_id')
    account.o_id = response.get('id')
    account.name = response.get('name')
    account.gender = response.get('gender')
    account.link = response.get('link')
    account.locale = response.get('locale')

    return account
Ejemplo n.º 2
0
    def create_account(self, db_session, email_address, response):
        email_address = response.get('emails')['account']
        try:
            account = db_session.query(OutlookAccount).filter_by(
                email_address=email_address).one()
        except sqlalchemy.orm.exc.NoResultFound:
            namespace = Namespace()
            account = OutlookAccount(namespace=namespace)

        account.refresh_token = response['refresh_token']
        account.date = datetime.datetime.utcnow()
        tok = response.get('access_token')
        expires_in = response.get('expires_in')
        account.set_access_token(tok, expires_in)
        account.scope = response.get('scope')
        account.email_address = email_address
        account.o_id_token = response.get('user_id')
        account.o_id = response.get('id')
        account.name = response.get('name')
        account.gender = response.get('gender')
        account.link = response.get('link')
        account.locale = response.get('locale')

        # Hack to ensure that account syncs get restarted if they were stopped
        # because of e.g. invalid credentials and the user re-auths.
        # TODO(emfree): remove after status overhaul.
        if account.sync_state != 'running':
            account.sync_state = None

        return account
Ejemplo n.º 3
0
 def create_account(self, account_data):
     namespace = Namespace()
     account = OutlookAccount(namespace=namespace)
     account.create_emailed_events_calendar()
     account.sync_should_run = False
     return self.update_account(account, account_data)
Ejemplo n.º 4
0
    def create_account(self, db_session, email_address, response):
        email_address = response.get('emails')['account']
        try:
            account = db_session.query(OutlookAccount).filter_by(
                email_address=email_address).one()
        except sqlalchemy.orm.exc.NoResultFound:
            namespace = Namespace()
            account = OutlookAccount(namespace=namespace)

        account.refresh_token = response['refresh_token']
        account.date = datetime.datetime.utcnow()
        tok = response.get('access_token')
        expires_in = response.get('expires_in')
        token_manager.cache_token(account, tok, expires_in)
        account.scope = response.get('scope')
        account.email_address = email_address
        account.o_id_token = response.get('user_id')
        account.o_id = response.get('id')
        account.name = response.get('name')
        account.gender = response.get('gender')
        account.link = response.get('link')
        account.locale = response.get('locale')

        # Unlike Gmail, Outlook doesn't return the client_id and secret here
        account.client_id = OAUTH_CLIENT_ID
        account.client_secret = OAUTH_CLIENT_SECRET

        # Ensure account has sync enabled.
        account.enable_sync()

        return account
Ejemplo n.º 5
0
Archivo: outlook.py Proyecto: wmv/inbox
def create_account(db_session, response):
    email_address = response.get('emails')['account']
    try:
        account = db_session.query(OutlookAccount).filter_by(
            email_address=email_address).one()
    except sqlalchemy.orm.exc.NoResultFound:
        namespace = Namespace()
        account = OutlookAccount(namespace=namespace)

    account.refresh_token = response['refresh_token']
    account.date = datetime.datetime.utcnow()
    tok = response.get('access_token')
    expires_in = response.get('expires_in')
    account.set_access_token(tok, expires_in)
    account.scope = response.get('scope')
    account.email_address = email_address
    account.o_id_token = response.get('user_id')
    account.o_id = response.get('id')
    account.name = response.get('name')
    account.gender = response.get('gender')
    account.link = response.get('link')
    account.locale = response.get('locale')

    return account
Ejemplo n.º 6
0
    def create_account(self, db_session, email_address, response):
        email_address = response.get('emails')['account']
        try:
            account = db_session.query(OutlookAccount).filter_by(
                email_address=email_address).one()
        except sqlalchemy.orm.exc.NoResultFound:
            namespace = Namespace()
            account = OutlookAccount(namespace=namespace)

        account.refresh_token = response['refresh_token']
        account.date = datetime.datetime.utcnow()
        tok = response.get('access_token')
        expires_in = response.get('expires_in')
        token_manager.cache_token(account, tok, expires_in)
        account.scope = response.get('scope')
        account.email_address = email_address
        account.o_id_token = response.get('user_id')
        account.o_id = response.get('id')
        account.name = response.get('name')
        account.gender = response.get('gender')
        account.link = response.get('link')
        account.locale = response.get('locale')

        # Unlike Gmail, Outlook doesn't return the client_id and secret here
        account.client_id = OAUTH_CLIENT_ID
        account.client_secret = OAUTH_CLIENT_SECRET

        # Ensure account has sync enabled.
        account.enable_sync()

        return account