'Returns an AuthorizationCode fetched from a storage.
:param code: The authorization code.
:return: An instance of :class:`oauth2.datatype.AuthorizationCode`.
:raises: :class:`oauth2.error.AuthCodeNotFound` if no data could be retrieved for
given code.'

def fetch_by_code(self, code):

    orm_code = self.db.query(orm.OAuthCode).filter((orm.OAuthCode.code == code)).first()
    if (orm_code is None):
        raise AuthCodeNotFound()
    else:
        return AuthorizationCode(client_id=orm_code.client_id, code=code, expires_at=orm_code.expires_at, redirect_uri=orm_code.redirect_uri, scopes=[], user_id=orm_code.user_id)
