当前位置: 首页>>代码示例>>Python>>正文


Python spotipy.oauth2方法代码示例

本文整理汇总了Python中spotipy.oauth2方法的典型用法代码示例。如果您正苦于以下问题:Python spotipy.oauth2方法的具体用法?Python spotipy.oauth2怎么用?Python spotipy.oauth2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在spotipy的用法示例。


在下文中一共展示了spotipy.oauth2方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _generate_token

# 需要导入模块: import spotipy [as 别名]
# 或者: from spotipy import oauth2 [as 别名]
def _generate_token(self, client_id, client_secret):
        credentials = oauth2.SpotifyClientCredentials(
            client_secret=client_secret,
        )
        token = credentials.get_access_token()
        return token 
开发者ID:ritiek,项目名称:spotify-downloader,代码行数:8,代码来源:spotify.py

示例2: __init__

# 需要导入模块: import spotipy [as 别名]
# 或者: from spotipy import oauth2 [as 别名]
def __init__(self, client_id=None, client_secret=None):
        global masterclient
        # `spotipy.Spotify` makes use of `self._session` and would
        # result in an error. The below line is a workaround.
        self._session = None

        credentials_provided = client_id is not None \
                           and client_secret is not None
        valid_input = credentials_provided or masterclient is not None

        if not valid_input:
            raise SpotifyAuthorizationError(
                "You must pass in client_id and client_secret to this method "
                "when authenticating for the first time."
            )

        if masterclient:
            logger.debug("Reading cached master Spotify credentials.")
            # Use cached client instead of authorizing again
            # and thus wasting time.
            self.__dict__.update(masterclient.__dict__)
        else:
            logger.debug("Setting master Spotify credentials.")
            credential_manager = oauth2.SpotifyClientCredentials(
                client_id=client_id,
                client_secret=client_secret
            )
            super().__init__(client_credentials_manager=credential_manager)
            # Cache current client
            masterclient = self 
开发者ID:ritiek,项目名称:spotify-downloader,代码行数:32,代码来源:spotify.py

示例3: getCredentials

# 需要导入模块: import spotipy [as 别名]
# 或者: from spotipy import oauth2 [as 别名]
def getCredentials(self):
        try:
            return spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
        except spotipy.oauth2.SpotifyOauthError:
            print('Did not find Spotify credentials.')

            print('Please visit https://github.com/bjarneo/pytify#credentials for more information.')

            sys.exit(1)

    # query 
开发者ID:bjarneo,项目名称:Pytify,代码行数:13,代码来源:pytifylib.py

示例4: register

# 需要导入模块: import spotipy [as 别名]
# 或者: from spotipy import oauth2 [as 别名]
def register():
    client_id = needl.settings["spotify"]["client_id"]
    client_secret = needl.settings["spotify"]["client_secret"]
    if client_id and client_secret:
        os.environ["SPOTIPY_CLIENT_ID"] = client_id
        os.environ["SPOTIPY_CLIENT_SECRET"] = client_secret
        client_credentials_manager = spotipy.oauth2.SpotifyClientCredentials()
        global spotify_client
        spotify_client = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
        search_interval = needl.settings['spotify']['search_interval']
        args = map(int, search_interval.split('..'))
        needl.schedule.every(*args).minutes.do(search_artist) 
开发者ID:eth0izzle,项目名称:Needl,代码行数:14,代码来源:spotify.py

示例5: _load_token

# 需要导入模块: import spotipy [as 别名]
# 或者: from spotipy import oauth2 [as 别名]
def _load_token(self):
    try:
      import spotipy.oauth2
      callback_url = '{}{}'.format(self.hass.config.api.base_url, AUTH_CALLBACK_PATH)
      cache = self.config.get(CONF_CACHE_PATH, self.hass.config.path(DEFAULT_CACHE_PATH))
      self.oauth = spotipy.oauth2.SpotifyOAuth(
            self.config.get(CONF_CLIENT_ID), self.config.get(CONF_CLIENT_SECRET),
            callback_url, scope=SCOPE,
            cache_path=cache)
      self.token_info = self.oauth.get_cached_token()
    except Exception as e:
      LOGGER.error("Could not refresh token")
      LOGGER.error(e) 
开发者ID:macbury,项目名称:SmartHouse,代码行数:15,代码来源:sensor.py


注:本文中的spotipy.oauth2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。