#NEWLINE# def authenticate_request( self , request ) : #NEWLINE# #INDENT# 'Append the required authentication headers\n        to the specified request. This will only function\n        if a session has been successfully created using\n        :func:`authenticate`. This will also refresh the\n        authentication token if necessary.\n\n        Args:\n            request (:class:`RequestBase<onedrivesdk.request_base.RequestBase>`):\n                The request to authenticate\n        ' #NEWLINE# if ( self . _session is None ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Session must be authenticated \n                before applying authentication to a request.' ) #NEWLINE# #UNINDENT# if ( self . _session . is_expired ( ) and ( 'wl.offline_access' in self . scopes ) ) : #NEWLINE# #INDENT# self . refresh_token ( ) #NEWLINE# #UNINDENT# request . append_option ( HeaderOption ( 'Authorization' , 'bearer {}' . format ( self . _session . access_token ) ) )