Add OAuth parameters to the request. Parameters may be included from the body if the content-type is urlencoded, if no content type is set, a guess is made.
(self, method, uri, headers, body)
| 159 | return uri, headers, body |
| 160 | |
| 161 | def prepare(self, method, uri, headers, body): |
| 162 | """Add OAuth parameters to the request. |
| 163 | |
| 164 | Parameters may be included from the body if the content-type is |
| 165 | urlencoded, if no content type is set, a guess is made. |
| 166 | """ |
| 167 | content_type = to_native(headers.get("Content-Type", "")) |
| 168 | if self.signature_type == SIGNATURE_TYPE_BODY: |
| 169 | content_type = CONTENT_TYPE_FORM_URLENCODED |
| 170 | elif not content_type and extract_params(body): |
| 171 | content_type = CONTENT_TYPE_FORM_URLENCODED |
| 172 | |
| 173 | if CONTENT_TYPE_FORM_URLENCODED in content_type: |
| 174 | headers["Content-Type"] = CONTENT_TYPE_FORM_URLENCODED |
| 175 | if isinstance(body, bytes): |
| 176 | body = body.decode() |
| 177 | uri, headers, body = self.sign(method, uri, headers, body) |
| 178 | elif self.force_include_body: |
| 179 | # To allow custom clients to work on non form encoded bodies. |
| 180 | uri, headers, body = self.sign(method, uri, headers, body) |
| 181 | else: |
| 182 | # Omit body data in the signing of non form-encoded requests |
| 183 | uri, headers, _ = self.sign(method, uri, headers, b"") |
| 184 | body = b"" |
| 185 | return uri, headers, body |
| 186 | |
| 187 | |
| 188 | def generate_nonce(): |
nothing calls this directly
no test coverage detected