common
oauthlib.common ~~~~~~~~~~~~~~
This module provides data structures and utilities common to all implementations of OAuth.
CaseInsensitiveDict
Bases: dict
Basic case insensitive dict with strings only keys.
Source code in server/vendor/oauthlib/common.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
|
Request
A malleable representation of a signable HTTP request.
Body argument may contain any data, but parameters will only be decoded if they are one of:
- urlencoded query string
- dict
- list of 2-tuples
Anything else will be treated as raw body data to be passed through unmolested.
Source code in server/vendor/oauthlib/common.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
add_params_to_qs(query, params)
Extend a query with a list of two-tuples.
Source code in server/vendor/oauthlib/common.py
233 234 235 236 237 238 239 |
|
add_params_to_uri(uri, params, fragment=False)
Add a list of two-tuples to the uri query components.
Source code in server/vendor/oauthlib/common.py
242 243 244 245 246 247 248 249 |
|
decode_params_utf8(params)
Ensures that all parameters in a list of 2-element tuples are decoded to unicode using UTF-8.
Source code in server/vendor/oauthlib/common.py
84 85 86 87 88 89 90 91 92 93 |
|
encode_params_utf8(params)
Ensures that all parameters in a list of 2-element tuples are encoded to bytestrings using UTF-8
Source code in server/vendor/oauthlib/common.py
72 73 74 75 76 77 78 79 80 81 |
|
extract_params(raw)
Extract parameters and return them as a list of 2-tuples.
Will successfully extract parameters from urlencoded query strings, dicts, or lists of 2-tuples. Empty strings/dicts/lists will return an empty list of parameters. Any other input will result in a return value of None.
Source code in server/vendor/oauthlib/common.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
generate_client_id(length=30, chars=CLIENT_ID_CHARACTER_SET)
Generates an OAuth client_id
OAuth 2 specify the format of client_id in https://tools.ietf.org/html/rfc6749#appendix-A.
Source code in server/vendor/oauthlib/common.py
224 225 226 227 228 229 230 |
|
generate_nonce()
Generate pseudorandom nonce that is unlikely to repeat.
Per section 3.3
of the OAuth 1 RFC 5849 spec. Per section 3.2.1
of the MAC Access Authentication spec.
A random 64-bit number is appended to the epoch timestamp for both randomness and to decrease the likelihood of collisions.
.. section 3.2.1
: https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01#section-3.2.1 .. section 3.3
: https://tools.ietf.org/html/rfc5849#section-3.3
Source code in server/vendor/oauthlib/common.py
161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
generate_timestamp()
Get seconds since epoch (UTC).
Per section 3.3
of the OAuth 1 RFC 5849 spec. Per section 3.2.1
of the MAC Access Authentication spec.
.. section 3.2.1
: https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01#section-3.2.1 .. section 3.3
: https://tools.ietf.org/html/rfc5849#section-3.3
Source code in server/vendor/oauthlib/common.py
176 177 178 179 180 181 182 183 184 185 |
|
generate_token(length=30, chars=UNICODE_ASCII_CHARACTER_SET)
Generates a non-guessable OAuth token
OAuth (1 and 2) does not specify the format of tokens except that they should be strings of random characters. Tokens should not be guessable and entropy when generating the random characters is important. Which is why SystemRandom is used instead of the default random.choice method.
Source code in server/vendor/oauthlib/common.py
188 189 190 191 192 193 194 195 196 197 |
|
safe_string_equals(a, b)
Near-constant time string comparison.
Used in order to avoid timing attacks on sensitive information such as secret keys during request verification (rootLabs
_).
.. _rootLabs
: http://rdist.root.org/2010/01/07/timing-independent-array-comparison/
Source code in server/vendor/oauthlib/common.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
to_unicode(data, encoding='UTF-8')
Convert a number of different types of objects to unicode.
Source code in server/vendor/oauthlib/common.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
urldecode(query)
Decode a query string in x-www-form-urlencoded format into a sequence of two-element tuples.
Unlike urlparse.parse_qsl(..., strict_parsing=True) urldecode will enforce correct formatting of the query string by validation. If validation fails a ValueError will be raised. urllib.parse_qsl will only raise errors if any of name-value pairs omits the equals sign.
Source code in server/vendor/oauthlib/common.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|