()
return new_discovery_document
Get Google OAuth2 discovery document.

    The document is cached in order to limit the amount of network round trips
    and is set to expire in 12 hours from when it was fetched.

    Returns:
        Discovery document as a dictionary.
Get Google OAuth2 discovery document.
Get Google OAuth2 discovery document .
def get_oauth2_discovery_document():
    """Get Google OAuth2 discovery document.

    The document is cached in order to limit the amount of network round trips
    and is set to expire in 12 hours from when it was fetched.

    Returns:
        Discovery document as a dictionary.
    """
    now = int(time.time())
    cache = get_oauth2_discovery_document.cache
    discovery_document = cache.get('current')
    if discovery_document:
        # Check if the document has expired.
        created_at = discovery_document['created_at']
        expires_at = created_at + 12*60*60  # 12 hours in seconds
        if now < expires_at:
            return discovery_document['document']

    # Re-fetch the discovery document.
    new_discovery_document = _fetch_oauth2_discovery_document()
    cache = {
        'current': {
            'created_at': now,
            'document': new_discovery_document
        }
    }
    get_oauth2_discovery_document.cache = cache
    return new_discovery_document
def get_oauth2_discovery_document ( ) : now = int ( time . time ( ) ) cache = get_oauth2_discovery_document . cache discovery_document = cache . get ( 'current' ) if discovery_document : # Check if the document has expired. created_at = discovery_document [ 'created_at' ] expires_at = created_at + 12 * 60 * 60 # 12 hours in seconds if now < expires_at : return discovery_document [ 'document' ] # Re-fetch the discovery document. new_discovery_document = _fetch_oauth2_discovery_document ( ) cache = { 'current' : { 'created_at' : now , 'document' : new_discovery_document } } get_oauth2_discovery_document . cache = cache return new_discovery_document