<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def request_error_header(exception):
 """ Generates the error header for a request using a Bearer token based on a given OAuth exception. """


    from .conf import options
    
    header = "Bearer realm=\"%s\"" % (options.realm, )
    
    if hasattr(exception, "error"):
        header = header + ", error=\"%s\"" % (exception.error, )
    
    if hasattr(exception, "reason"):
        header = header + ", error_description=\"%s\"" % (exception.reason, )
    
    return header