'Creates a new HttpRpcServerOAuth2.
Args:
host: The host to send requests to.
oauth2_parameters: An object of type OAuth2Parameters (defined above)
that specifies all parameters related to OAuth2 authentication. (This
replaces the auth_function parameter in the parent class.)
user_agent: The user-agent string to send to the server. Specify None to
omit the user-agent header.
source: Saved but ignored.
host_override: The host header to send to the server (defaults to host).
extra_headers: A dict of extra headers to append to every request. Values
supplied here will override other default headers that are supplied.
save_cookies: If the refresh token should be saved.
auth_tries: The number of times to attempt auth_function before failing.
account_type: Ignored.
debug_data: Whether debugging output should include data contents.
secure: If the requests sent using Send should be sent over HTTPS.
ignore_certs: If the certificate mismatches should be ignored.
rpc_tries: The number of rpc retries upon http server error (i.e.
Response code >= 500 and < 600) before failing.
options: the command line options.
http_class: the httplib2.Http subclass to use. Defaults to httplib2.Http.'

def __init__(self, host, oauth2_parameters, user_agent, source, host_override=None, extra_headers=None, save_cookies=False, auth_tries=None, account_type=None, debug_data=True, secure=True, ignore_certs=False, rpc_tries=3, options=None, http_class=None):

    super(HttpRpcServerOAuth2, self).__init__(host, None, user_agent, source, host_override=host_override, extra_headers=extra_headers, auth_tries=auth_tries, debug_data=debug_data, secure=secure, ignore_certs=ignore_certs, rpc_tries=rpc_tries, save_cookies=save_cookies, http_class=http_class)
    if (not isinstance(oauth2_parameters, self.OAuth2Parameters)):
        raise TypeError(('oauth2_parameters    must    be    an    OAuth2Parameters:    %r' % oauth2_parameters))
    self.oauth2_parameters = oauth2_parameters
    if save_cookies:
        oauth2_credential_file = (oauth2_parameters.credential_file or '~/.appcfg_oauth2_tokens')
        self.storage = oauth2client_file.Storage(os.path.expanduser(oauth2_credential_file))
    else:
        self.storage = NoStorage()
    if oauth2_parameters.credentials:
        self.credentials = oauth2_parameters.credentials
    elif any((oauth2_parameters.access_token, oauth2_parameters.refresh_token, oauth2_parameters.token_uri)):
        token_uri = (oauth2_parameters.token_uri or ('https://%s/o/oauth2/token' % os.getenv('APPENGINE_AUTH_SERVER', 'accounts.google.com')))
        self.credentials = client.OAuth2Credentials(oauth2_parameters.access_token, oauth2_parameters.client_id, oauth2_parameters.client_secret, oauth2_parameters.refresh_token, None, token_uri, self.user_agent)
    else:
        self.credentials = self.storage.get()
    self.flags = self.FlowFlags(options)
