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


Python config.CLIENT_ID属性代码示例

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


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

示例1: login

# 需要导入模块: import config [as 别名]
# 或者: from config import CLIENT_ID [as 别名]
def login():
    """Prompt user to authenticate."""
    auth_state = str(uuid.uuid4())
    SESSION.auth_state = auth_state

    # For this sample, the user selects an account to authenticate. Change
    # this value to 'none' for "silent SSO" behavior, and if the user is
    # already authenticated they won't need to re-authenticate.
    prompt_behavior = 'select_account'

    params = urllib.parse.urlencode({'response_type': 'code',
                                     'client_id': config.CLIENT_ID,
                                     'redirect_uri': config.REDIRECT_URI,
                                     'state': auth_state,
                                     'resource': config.RESOURCE,
                                     'prompt': prompt_behavior})

    return bottle.redirect(config.AUTHORITY_URL + '/oauth2/authorize?' + params) 
开发者ID:microsoftgraph,项目名称:python-sample-auth,代码行数:20,代码来源:sample_adal_bottle.py

示例2: authorized

# 需要导入模块: import config [as 别名]
# 或者: from config import CLIENT_ID [as 别名]
def authorized():
    """Handler for the application's Redirect Uri."""
    code = bottle.request.query.code
    auth_state = bottle.request.query.state
    if auth_state != SESSION.auth_state:
        raise Exception('state returned to redirect URL does not match!')
    auth_context = adal.AuthenticationContext(config.AUTHORITY_URL, api_version=None)
    token_response = auth_context.acquire_token_with_authorization_code(
        code, config.REDIRECT_URI, config.RESOURCE, config.CLIENT_ID, config.CLIENT_SECRET)
    SESSION.headers.update({'Authorization': f"Bearer {token_response['accessToken']}",
                            'User-Agent': 'adal-sample',
                            'Accept': 'application/json',
                            'Content-Type': 'application/json',
                            'SdkVersion': 'sample-python-adal',
                            'return-client-request-id': 'true'})
    return bottle.redirect('/graphcall') 
开发者ID:microsoftgraph,项目名称:python-sample-auth,代码行数:18,代码来源:sample_adal_bottle.py

示例3: login

# 需要导入模块: import config [as 别名]
# 或者: from config import CLIENT_ID [as 别名]
def login():
    """Prompt user to authenticate."""
    auth_state = str(uuid.uuid4())
    SESSION.auth_state = auth_state

    # For this sample, the user selects an account to authenticate. Change
    # this value to 'none' for "silent SSO" behavior, and if the user is
    # already authenticated they won't need to re-authenticate.
    prompt_behavior = 'select_account'

    params = urllib.parse.urlencode({'response_type': 'code',
                                     'client_id': config.CLIENT_ID,
                                     'redirect_uri': config.REDIRECT_URI,
                                     'state': auth_state,
                                     'resource': config.RESOURCE,
                                     'prompt': prompt_behavior})

    return flask.redirect(config.AUTHORITY_URL + '/oauth2/authorize?' + params) 
开发者ID:microsoftgraph,项目名称:python-sample-auth,代码行数:20,代码来源:sample_adal.py

示例4: authorized

# 需要导入模块: import config [as 别名]
# 或者: from config import CLIENT_ID [as 别名]
def authorized():
    """Handler for the application's Redirect Uri."""
    code = flask.request.args['code']
    auth_state = flask.request.args['state']
    if auth_state != SESSION.auth_state:
        raise Exception('state returned to redirect URL does not match!')
    auth_context = adal.AuthenticationContext(config.AUTHORITY_URL, api_version=None)
    token_response = auth_context.acquire_token_with_authorization_code(
        code, config.REDIRECT_URI, config.RESOURCE, config.CLIENT_ID, config.CLIENT_SECRET)
    SESSION.headers.update({'Authorization': f"Bearer {token_response['accessToken']}",
                            'User-Agent': 'adal-sample',
                            'Accept': 'application/json',
                            'Content-Type': 'application/json',
                            'SdkVersion': 'sample-python-adal',
                            'return-client-request-id': 'true'})
    return flask.redirect('/graphcall') 
开发者ID:microsoftgraph,项目名称:python-sample-auth,代码行数:18,代码来源:sample_adal.py

示例5: setUpClass

# 需要导入模块: import config [as 别名]
# 或者: from config import CLIENT_ID [as 别名]
def setUpClass(self):
        self.api_base_url                   = config.BASE_URL or 'http://api.dailymotion.com'
        self.api_key                        = config.CLIENT_ID
        self.api_secret                     = config.CLIENT_SECRET
        self.username                       = config.USERNAME
        self.password                       = config.PASSWORD
        self.scope                          = ['manage_videos', 'manage_playlists', 'userinfo']
        self.redirect_uri                   = config.REDIRECT_URI
        self.oauth_authorize_endpoint_url   = config.OAUTH_AUTHORIZE_URL or 'https://api.dailymotion.com/oauth/authorize'
        self.oauth_token_endpoint_url       = config.OAUTH_TOKEN_URL or 'https://api.dailymotion.com/oauth/token'
        self.session_file_directory  = './data'
        if not os.path.exists(self.session_file_directory):
            os.makedirs(self.session_file_directory) 
开发者ID:dailymotion,项目名称:dailymotion-sdk-python,代码行数:15,代码来源:TestDailymotion.py

示例6: get_account

# 需要导入模块: import config [as 别名]
# 或者: from config import CLIENT_ID [as 别名]
def get_account():
    """Method that provides the connection to Reddit API using OAuth.
        :return: Reddit instance.
    """
    return praw.Reddit(client_id=config.CLIENT_ID,
                       client_secret=config.CLIENT_SECRET,
                       user_agent=config.USER_AGENT,
                       username=config.USERNAME,
                       password=config.PASSWORD) 
开发者ID:Jonarzz,项目名称:DotaResponsesRedditBot,代码行数:11,代码来源:account.py

示例7: __init__

# 需要导入模块: import config [as 别名]
# 或者: from config import CLIENT_ID [as 别名]
def __init__(self, **kwargs):
        """Initialize instance with default values and user-provided overrides.

        The only argument that MUST be specified at runtime is scopes, the list
        of required scopes for this session.

        These settings have default values imported from config.py, but can
        be overridden if desired:
        client_id = client ID (application ID) from app registration portal
        client_secret = client secret (password) from app registration portal
        redirect_uri = must match value specified in app registration portal
        resource = the base URL for calls to Microsoft Graph
        api_version = Graph version ('v1.0' is default, can also use 'beta')
        authority_url = base URL for authorization authority
        auth_endpoint = authentication endpoint (at authority_url)
        token_endpoint = token endpoint (at authority_url)
        cache_state = whether to cache session state in local state.json file
                      If cache_state==True and a valid access token has been
                      cached, the token will be used without any user
                      authentication required ("silent SSO")
        refresh_enable = whether to auto-refresh expired tokens
        """

        self.config = {'client_id': config.CLIENT_ID,
                       'client_secret': config.CLIENT_SECRET,
                       'redirect_uri': config.REDIRECT_URI,
                       'scopes': config.SCOPES,
                       'cache_state': False,
                       'resource': config.RESOURCE,
                       'api_version': config.API_VERSION,
                       'authority_url': config.AUTHORITY_URL,
                       'auth_endpoint': config.AUTHORITY_URL + config.AUTH_ENDPOINT,
                       'token_endpoint': config.AUTHORITY_URL + config.TOKEN_ENDPOINT,
                       'refresh_enable': True}

        # Print warning if any unknown arguments were passed, since those may be
        # errors/typos.
        for key in kwargs:
            if key not in self.config:
                print(f'WARNING: unknown "{key}" argument passed to GraphSession')

        self.config.update(kwargs.items()) # add passed arguments to config

        self.state_manager('init')

        # used by login() and redirect_uri_handler() to identify current session
        self.authstate = ''

        # route to redirect to after authentication; can be overridden in login()
        self.login_redirect = '/'

        # If refresh tokens are enabled, add the offline_access scope.
        # Note that refresh_enable setting takes precedence over whether
        # the offline_access scope is explicitly requested.
        refresh_scope = 'offline_access'
        if self.config['refresh_enable']:
            if refresh_scope not in self.config['scopes']:
                self.config['scopes'].append(refresh_scope)
        elif refresh_scope in self.config['scopes']:
                self.config['scopes'].remove(refresh_scope) 
开发者ID:microsoftgraph,项目名称:python-sample-auth,代码行数:62,代码来源:graphrest.py


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