#NEWLINE# def CreateHttpHeader( self ) : #NEWLINE# #INDENT# "Creates an OAuth2 HTTP header.\n\n    The OAuth2 credentials will be refreshed as necessary. In the event that\n    the credentials fail to refresh, a message is logged but no exception is\n    raised.\n\n    Returns:\n      A dictionary containing one entry: the OAuth2 Bearer header under the\n      'Authorization' key.\n\n    Raises:\n      AccessTokenRefreshError: If the refresh fails.\n    " #NEWLINE# oauth2_header = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( ( self . oauth2credentials . token_expiry is not None ) and ( ( self . oauth2credentials . token_expiry - datetime . datetime . utcnow ( ) ) < datetime . timedelta ( minutes = oauth2_header . _OAUTH2_REFRESH_MINUTES_IN_ADVANCE ) ) ) : #NEWLINE# #INDENT# self . Refresh ( ) #NEWLINE# #UNINDENT# self . oauth2credentials . apply ( oauth2_header ) #NEWLINE# return oauth2_header