MCPcopy Create free account
hub / github.com/oauthlib/oauthlib / extract_params

Function extract_params

oauthlib/common.py:132–158  ·  view source on GitHub ↗

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.

(raw)

Source from the content-addressed store, hash-verified

130
131
132def extract_params(raw):
133 """Extract parameters and return them as a list of 2-tuples.
134
135 Will successfully extract parameters from urlencoded query strings,
136 dicts, or lists of 2-tuples. Empty strings/dicts/lists will return an
137 empty list of parameters. Any other input will result in a return
138 value of None.
139 """
140 if isinstance(raw, (bytes, str)):
141 try:
142 params = urldecode(raw)
143 except ValueError:
144 params = None
145 elif hasattr(raw, '__iter__'):
146 try:
147 dict(raw)
148 except ValueError:
149 params = None
150 except TypeError:
151 params = None
152 else:
153 params = list(raw.items() if isinstance(raw, dict) else raw)
154 params = decode_params_utf8(params)
155 else:
156 params = None
157
158 return params
159
160
161def generate_nonce():

Calls 2

urldecodeFunction · 0.85
decode_params_utf8Function · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…