當前位置: 首頁>>代碼示例>>Python>>正文


Python config.API_VERSION屬性代碼示例

本文整理匯總了Python中config.API_VERSION屬性的典型用法代碼示例。如果您正苦於以下問題:Python config.API_VERSION屬性的具體用法?Python config.API_VERSION怎麽用?Python config.API_VERSION使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在config的用法示例。


在下文中一共展示了config.API_VERSION屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: graphcall

# 需要導入模塊: import config [as 別名]
# 或者: from config import API_VERSION [as 別名]
def graphcall():
    """Confirm user authentication by calling Graph and displaying some data."""
    endpoint = config.RESOURCE + config.API_VERSION + '/me'
    headers = {'SdkVersion': 'sample-python-requests-0.1.0',
               'x-client-SKU': 'sample-python-requests',
               'SdkVersion': 'sample-python-requests',
               'client-request-id': str(uuid.uuid4()),
               'return-client-request-id': 'true'}
    graphdata = MSGRAPH.get(endpoint, headers=headers).json()
    return {'graphdata': graphdata, 'endpoint': endpoint, 'sample': 'Requests-OAuthlib'} 
開發者ID:microsoftgraph,項目名稱:python-sample-auth,代碼行數:12,代碼來源:sample_requests.py

示例2: graphcall

# 需要導入模塊: import config [as 別名]
# 或者: from config import API_VERSION [as 別名]
def graphcall():
    """Confirm user authentication by calling Graph and displaying some data."""
    endpoint = 'me'
    headers = {'SdkVersion': 'sample-python-flask',
               'x-client-SKU': 'sample-python-flask',
               'client-request-id': str(uuid.uuid4()),
               'return-client-request-id': 'true'}
    graphdata = MSGRAPH.get(endpoint, headers=headers).data
    return flask.render_template('graphcall.html',
                                 graphdata=graphdata,
                                 endpoint=config.RESOURCE + config.API_VERSION + '/' + endpoint,
                                 sample='Flask-OAuthlib') 
開發者ID:microsoftgraph,項目名稱:python-sample-auth,代碼行數:14,代碼來源:sample_flask.py

示例3: graphcall

# 需要導入模塊: import config [as 別名]
# 或者: from config import API_VERSION [as 別名]
def graphcall():
    """Confirm user authentication by calling Graph and displaying some data."""
    endpoint = config.RESOURCE + config.API_VERSION + '/me'
    http_headers = {'client-request-id': str(uuid.uuid4())}
    graphdata = SESSION.get(endpoint, headers=http_headers, stream=False).json()
    return {'graphdata': graphdata, 'endpoint': endpoint, 'sample': 'ADAL'} 
開發者ID:microsoftgraph,項目名稱:python-sample-auth,代碼行數:8,代碼來源:sample_adal_bottle.py

示例4: graphcall

# 需要導入模塊: import config [as 別名]
# 或者: from config import API_VERSION [as 別名]
def graphcall():
    """Confirm user authentication by calling Graph and displaying some data."""
    endpoint = config.RESOURCE + config.API_VERSION + '/me'
    http_headers = {'client-request-id': str(uuid.uuid4())}
    graphdata = SESSION.get(endpoint, headers=http_headers, stream=False).json()
    return flask.render_template('graphcall.html',
                                 graphdata=graphdata,
                                 endpoint=endpoint,
                                 sample='ADAL') 
開發者ID:microsoftgraph,項目名稱:python-sample-auth,代碼行數:11,代碼來源:sample_adal.py

示例5: api_endpoint

# 需要導入模塊: import config [as 別名]
# 或者: from config import API_VERSION [as 別名]
def api_endpoint(url):
    """Convert a relative path such as /me/photo/$value to a full URI based
    on the current RESOURCE and API_VERSION settings in config.py.
    """
    if urllib.parse.urlparse(url).scheme in ['http', 'https']:
        return url # url is already complete
    return urllib.parse.urljoin(f'{config.RESOURCE}/{config.API_VERSION}/',
                                url.lstrip('/')) 
開發者ID:microsoftgraph,項目名稱:python-sample-console-app,代碼行數:10,代碼來源:helpers.py

示例6: __init__

# 需要導入模塊: import config [as 別名]
# 或者: from config import API_VERSION [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.API_VERSION屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。