def from_string(s): """ Returns a token from something like: oauth_token_secret=xxx&oauth_token=xxx """ params = parse_qs(s, keep_blank_values=False) key = params['oauth_token'][0] secret = params['oauth_token_secret'][0] token = OAuthToken(key, secret) try: token.callback_confirmed = params[b'oauth_callback_confirmed'][0] except KeyError: pass # 1.0, no callback confirmed. return token
def _split_url_string(param_str): """Turn URL string into parameters.""" parameters = parse_qs(param_str, keep_blank_values=False) for k, v in parameters.items(): parameters[k] = unquote(v[0]) return parameters