MCPcopy Index your code
hub / github.com/googleapis/google-api-python-client / authorize

Method authorize

tests/test_http.py:81–113  ·  view source on GitHub ↗
(self, http)

Source from the content-addressed store, hash-verified

79 return self._access_token_expired
80
81 def authorize(self, http):
82 self._authorized += 1
83
84 request_orig = http.request
85
86 # The closure that will replace 'httplib2.Http.request'.
87 def new_request(
88 uri,
89 method="GET",
90 body=None,
91 headers=None,
92 redirections=httplib2.DEFAULT_MAX_REDIRECTS,
93 connection_type=None,
94 ):
95 # Modify the request headers to add the appropriate
96 # Authorization header.
97 if headers is None:
98 headers = {}
99 self.apply(headers)
100
101 resp, content = request_orig(
102 uri, method, body, headers, redirections, connection_type
103 )
104
105 return resp, content
106
107 # Replace the request method with our own closure.
108 http.request = new_request
109
110 # Set credentials as a property of the request method.
111 setattr(http.request, "credentials", self)
112
113 return http
114
115 def refresh(self, http):
116 self._refreshed += 1

Callers 9

main.pyFile · 0.80
mainFunction · 0.80
mainFunction · 0.80
authorized_httpFunction · 0.80
initFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected