How to use the tekore._auth.scope.Scope function in tekore

To help you get started, we’ve selected a few tekore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github felix-hilden / spotipy / tekore / _auth / expiring.py View on Github external
def __init__(self, token_info: dict):
        self._access_token = token_info['access_token']
        self._token_type = token_info['token_type']

        self._scope = Scope(*token_info['scope'].split(' '))
        if str(self._scope) == '':
            self._scope = Scope()

        self._refresh_token = token_info.get('refresh_token', None)
        self._expires_at = int(time.time()) + token_info['expires_in']
github felix-hilden / spotipy / tekore / _auth / expiring.py View on Github external
def __init__(self, token_info: dict):
        self._access_token = token_info['access_token']
        self._token_type = token_info['token_type']

        self._scope = Scope(*token_info['scope'].split(' '))
        if str(self._scope) == '':
            self._scope = Scope()

        self._refresh_token = token_info.get('refresh_token', None)
        self._expires_at = int(time.time()) + token_info['expires_in']
github felix-hilden / spotipy / tekore / _auth / scope.py View on Github external
def __sub__(self, other) -> 'Scope':
        """Remove scope from another."""
        return Scope(self) - other
github felix-hilden / spotipy / tekore / _auth / expiring.py View on Github external
show_dialog
            force login dialog even if previously authorised

        Returns
        -------
        str
            login URL
        """
        payload = {
            'show_dialog': str(show_dialog).lower(),
            'client_id': self.client_id,
            'response_type': 'code',
            'redirect_uri': self.redirect_uri
        }
        if isinstance(scope, list):
            scope = Scope(*scope)
        if scope is not None:
            payload['scope'] = str(scope)
        if state is not None:
            payload['state'] = state

        return OAUTH_AUTHORIZE_URL + '?' + urlencode(payload)
github felix-hilden / spotipy / tekore / _auth / scope.py View on Github external
def __add__(self, other) -> 'Scope':
        """Combine two sets of scopes."""
        if isinstance(other, (str, scope)):
            other = {str(other)}
        elif not isinstance(other, Scope):
            e = f'Addition not defined for {type(self)} and {type(other)}!'
            raise NotImplementedError(e)
        return type(self)(*self.union(other))
github felix-hilden / spotipy / tekore / _auth / scope.py View on Github external
def __add__(self, other) -> 'Scope':
        """Combine to a set of scopes."""
        return Scope(self) + other
github felix-hilden / spotipy / tekore / _auth / scope.py View on Github external
def __rsub__(self, other) -> 'Scope':
        """Remove scope from another."""
        return other - Scope(self)
github felix-hilden / spotipy / tekore / _auth / scope.py View on Github external
scope.read = Scope(
    scope.user_read_email,
    scope.user_read_private,
    scope.user_top_read,
    scope.user_read_recently_played,
    scope.user_follow_read,
    scope.user_library_read,
    scope.user_read_currently_playing,
    scope.user_read_playback_state,
    scope.user_read_playback_position,
    scope.playlist_read_collaborative,
    scope.playlist_read_private
)
scope.write = Scope(
    scope.user_follow_modify,
    scope.user_library_modify,
    scope.user_modify_playback_state,
    scope.playlist_modify_public,
    scope.playlist_modify_private,
    scope.ugc_image_upload
)
scope.every = scope.read + scope.write
github felix-hilden / spotipy / tekore / _auth / scope.py View on Github external
def __rsub__(self, other) -> 'Scope':
        """Remove scopes from a set."""
        if not isinstance(other, (str, scope)):
            e = f'Difference not defined for {type(other)} and {type(self)}!'
            raise NotImplementedError(e)
        return Scope(other) - self