Python six.moves.urllib_parse.urlencode() Examples

The following are 30 code examples of six.moves.urllib_parse.urlencode(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module six.moves.urllib_parse , or try the search function .
Example #1
Source File: betfair.py    From betfair.py with MIT License 6 votes vote down vote up
def login(self, username, password):
        """Log in to Betfair. Sets `session_token` if successful.

        :param str username: Username
        :param str password: Password
        :raises: BetfairLoginError
        """
        response = self.session.post(
            os.path.join(self.identity_url, 'certlogin'),
            cert=self.cert_file,
            data=urllib.urlencode({
                'username': username,
                'password': password,
            }),
            headers={
                'X-Application': self.app_key,
                'Content-Type': 'application/x-www-form-urlencoded',
            },
            timeout=self.timeout,
        )
        utils.check_status_code(response, [httplib.OK])
        data = response.json()
        if data.get('loginStatus') != 'SUCCESS':
            raise exceptions.LoginError(response, data)
        self.session_token = data['sessionToken'] 
Example #2
Source File: rpnet.py    From script.module.resolveurl with GNU General Public License v2.0 6 votes vote down vote up
def get_media_url(self, host, media_id):
        username = self.get_setting('username')
        password = self.get_setting('password')
        url = 'https://premium.rpnet.biz/client_api.php'
        query = urllib_parse.urlencode({'username': username, 'password': password, 'action': 'generate', 'links': media_id})
        url = url + '?' + query
        response = self.net.http_GET(url).content
        response = json.loads(response)
        if 'links' in response and response['links']:
            link = response['links'][0]
            if 'generated' in link:
                return link['generated']
            elif 'error' in link:
                raise ResolverError(link['error'])
        else:
            msg = 'No Link Returned'
            if 'error' in response and response['error']:
                msg += ': %s' % (response['error'][0])
            raise ResolverError(msg) 
Example #3
Source File: megadebrid.py    From script.module.resolveurl with GNU General Public License v2.0 6 votes vote down vote up
def login(self):
        try:
            common.logger.log('Mega-debrid - Logging In')
            username = self.get_setting('username')
            password = self.get_setting('password')
            if username and password:
                url = self.base_url + '?' + urllib_parse.urlencode({'action': 'connectUser', 'login': username, 'password': password})
                html = self.net.http_GET(url, headers=self.headers).content
                js_data = json.loads(html)
                if js_data.get('response_code') == 'ok':
                    self.token = js_data['token']
                    return True
                else:
                    msg = js_data.get('response_text', 'Unknown Error')
            else:
                msg = 'No Username/Password'
        except Exception as e:
            msg = str(e)

        raise ResolverError('MD Login Failed: %s' % (msg)) 
Example #4
Source File: megadebrid.py    From script.module.resolveurl with GNU General Public License v2.0 6 votes vote down vote up
def get_media_url(self, host, media_id):
        common.logger.log('in get_media_url %s : %s' % (host, media_id))
        if self.token is None:
            raise ResolverError('No MD Token Available')

        url = self.base_url + '?' + urllib_parse.urlencode({'action': 'getLink', 'token': self.token})
        data = {'link': media_id}
        html = self.net.http_POST(url, form_data=data, headers=self.headers).content
        js_data = json.loads(html)
        if js_data.get('response_code') == 'ok':
            if 'debridLink' in js_data:
                stream_url = js_data['debridLink'].strip('"')
                if stream_url.startswith('http'):
                    return stream_url
                else:
                    msg = 'MD Unusable Link: %s' % (stream_url)
            else:
                msg = 'MD No Link'
        else:
            msg = js_data.get('response_text', 'Unknown MD Error during resolve')

        logger.log_warning(msg)
        if isinstance(msg, six.text_type) and six.PY2:
            msg = msg.encode('utf-8')
        raise ResolverError(msg) 
Example #5
Source File: query.py    From pagure with GNU General Public License v2.0 6 votes vote down vote up
def avatar_url_from_email(email, size=64, default="retro", dns=False):
    """
    Our own implementation since fas doesn't support this nicely yet.
    """
    if not email:
        return
    if dns:  # pragma: no cover
        # This makes an extra DNS SRV query, which can slow down our webapps.
        # It is necessary for libravatar federation, though.
        import libravatar

        return libravatar.libravatar_url(
            openid=email, size=size, default=default
        )
    else:
        query = urlencode({"s": size, "d": default})
        email = email.encode("utf-8")
        hashhex = hashlib.sha256(email).hexdigest()
        return "https://seccdn.libravatar.org/avatar/%s?%s" % (hashhex, query) 
Example #6
Source File: premiumize_me.py    From script.module.resolveurl with GNU General Public License v2.0 6 votes vote down vote up
def __direct_dl(self, media_id, torrent=False):
        try:
            data = urllib_parse.urlencode({'src': media_id})
            response = self.net.http_POST(direct_dl_path, form_data=data, headers=self.headers).content
            result = json.loads(response)
            if 'status' in result:
                if result.get('status') == 'success':
                    if torrent:
                        _videos = [(int(item.get('size')), item.get('link')) for item in result.get("content")
                                   if any(item.get('path').lower().endswith(x)
                                          for x in FORMATS)]
                        try:
                            return max(_videos)[1]
                        except ValueError:
                            raise ResolverError('Failed to locate largest video file')
                    else:
                        return result.get('location', None)
                else:
                    raise ResolverError('Link Not Found: Error Code: %s' % result.get('status'))
            else:
                raise ResolverError('Unexpected Response Received')
        except:
            pass

        return None 
Example #7
Source File: handlers_test.py    From jupyter_http_over_ws with Apache License 2.0 6 votes vote down vote up
def test_auth_url_provided_forwards_cookies_and_propagates_xsrf(self):
    auth_url = self.get_server_base_url() + '/fake-auth'
    encoded_query_args = urlparse.urlencode(
        {'jupyter_http_over_ws_auth_url': auth_url})

    request = self.get_ws_connection_request('http_over_websocket?' +
                                             encoded_query_args)
    client = yield websocket.websocket_connect(request)
    client.write_message(
        self.get_request_json(
            '/api/sessions', '1234', method='POST', body='somedata'))

    response_body = yield client.read_message()
    response = json.loads(response_body)
    self.assertEqual(200, response['status'])
    self.assertEqual('somedata',
                     base64.b64decode(response['data']).decode('utf-8'))
    self.assertEqual('1234', response['message_id'])
    self.assertIn(TEST_XSRF_HEADER, response['headers'])
    self.assertEqual(FAKE_XSRF_VALUE, response['headers'][TEST_XSRF_HEADER])
    self.assertTrue(response['done']) 
Example #8
Source File: handlers_test.py    From jupyter_http_over_ws with Apache License 2.0 6 votes vote down vote up
def test_auth_url_provided_forwards_cookies(self):
    auth_url = self.get_server_base_url() + '/fake-auth'
    encoded_query_args = urlparse.urlencode(
        {'jupyter_http_over_ws_auth_url': auth_url})

    request = self.get_ws_connection_request('http_over_websocket?' +
                                             encoded_query_args)

    client = yield websocket.websocket_connect(request)
    client.write_message(
        self.get_request_json('/requires-cookies-from-fake-auth', '1234'))

    response_body = yield client.read_message()
    response = json.loads(response_body)
    self.assertEqual(200, response['status'])
    # RequiresCookieFromFakeAuthHandler writes cookies that should have
    # been received by performing a request to the auth url.
    self.assertEqual('X-Test-Cookie: "1" X-Other-Test-Cookie: "2"',
                     base64.b64decode(response['data']).decode('utf-8'))
    self.assertEqual('1234', response['message_id'])
    self.assertTrue(response['done']) 
Example #9
Source File: handlers_test.py    From jupyter_http_over_ws with Apache License 2.0 6 votes vote down vote up
def test_auth_url_provided_fails(self):
    auth_url = self.get_server_base_url() + '/fake-auth?always_fail=1'
    encoded_query_args = urlparse.urlencode(
        {'jupyter_http_over_ws_auth_url': auth_url})

    request = self.get_ws_connection_request('http_over_websocket?' +
                                             encoded_query_args)

    client = yield websocket.websocket_connect(request)
    client.write_message(
        self.get_request_json('/requires-cookies-from-fake-auth', '1234'))

    response_body = yield client.read_message()
    response = json.loads(response_body)
    self.assertEqual('1234', response['message_id'])
    self.assertEqual(500, response['status'])
    self.assertEqual(
        'Uncaught server-side exception. Check logs for additional details.',
        response['statusText'])
    self.assertTrue(response['done']) 
Example #10
Source File: handlers_test.py    From jupyter_http_over_ws with Apache License 2.0 6 votes vote down vote up
def _assertCrossDomainRequestFails(self, auth_url):
    encoded_query_args = urlparse.urlencode(
        {'jupyter_http_over_ws_auth_url': auth_url})

    request = self.get_ws_connection_request('http_over_websocket?' +
                                             encoded_query_args)

    with testing.ExpectLog(
        'tornado.application',
        'Uncaught error when proxying request',
        required=True) as expect_log:
      client = yield websocket.websocket_connect(request)
      client.write_message(
          self.get_request_json('/requires-cookies-from-fake-auth-ws', '1234'))

      response_body = yield client.read_message()
      response = json.loads(response_body)
      self.assertEqual('1234', response['message_id'])
      self.assertEqual(500, response['status'])
      self.assertEqual(
          'Uncaught server-side exception. Check logs for additional details.',
          response['statusText'])
      self.assertTrue(response['done'])
      self.assertTrue(expect_log.logged_stack) 
Example #11
Source File: handlers_test.py    From jupyter_http_over_ws with Apache License 2.0 6 votes vote down vote up
def test_auth_url_provided_forwards_cookies(self):
    auth_url = self.get_server_base_url() + '/fake-auth'
    encoded_query_args = urlparse.urlencode(
        {'jupyter_http_over_ws_auth_url': auth_url})

    request = self.get_ws_connection_request(
        'http_over_websocket/proxied_ws/requires-cookies-from-fake-auth-ws?' +
        encoded_query_args)
    request.headers.add('Origin', ALLOWED_ORIGIN)

    client = yield websocket.websocket_connect(request)
    self.assertIsNotNone(client)

    client.write_message('')
    # RequiresCookieFromFakeAuthWebSocketHandler writes cookies that should have
    # been received by performing a request to the auth url.
    result = yield client.read_message()
    self.assertEqual('X-Test-Cookie: "1" X-Other-Test-Cookie: "2"', result) 
Example #12
Source File: handlers_test.py    From jupyter_http_over_ws with Apache License 2.0 6 votes vote down vote up
def _assertCrossDomainRequestFails(self, auth_url):
    encoded_query_args = urlparse.urlencode(
        {'jupyter_http_over_ws_auth_url': auth_url})

    request = self.get_ws_connection_request(
        'http_over_websocket/proxied_ws/requires-cookies-from-fake-auth-ws?' +
        encoded_query_args)
    request.headers.add('Origin', ALLOWED_ORIGIN)

    with testing.ExpectLog(
        'tornado.application',
        'Uncaught error when proxying request',
        required=True) as expect_log:
      client = yield websocket.websocket_connect(request)
      self.assertIsNotNone(client)

      msg = yield client.read_message()
      # Message of None indicates that the connection has been closed.
      self.assertIsNone(msg)
      self.assertEqual(500, client.close_code)
      self.assertTrue(expect_log.logged_stack) 
Example #13
Source File: khanacademy.py    From Dailyfresh-B2C with Apache License 2.0 6 votes vote down vote up
def unauthorized_token_request(self):
        """Return request for unauthorized token (first stage)"""

        params = self.request_token_extra_arguments()
        params.update(self.get_scope_argument())
        key, secret = self.get_key_and_secret()
        # decoding='utf-8' produces errors with python-requests on Python3
        # since the final URL will be of type bytes
        decoding = None if six.PY3 else 'utf-8'
        state = self.get_or_create_state()
        auth = OAuth1(
            key,
            secret,
            callback_uri=self.get_redirect_uri(state),
            decoding=decoding,
            signature_method=SIGNATURE_HMAC,
            signature_type=SIGNATURE_TYPE_QUERY
        )
        url = self.REQUEST_TOKEN_URL + '?' + urlencode(params)
        url, _, _ = auth.client.sign(url)
        return url 
Example #14
Source File: benchmarks.py    From zipline-chinese with Apache License 2.0 6 votes vote down vote up
def format_yahoo_index_url(symbol, start_date, end_date):
    """
    Format a URL for querying Yahoo Finance for Index data.
    """
    return (
        'http://ichart.finance.yahoo.com/table.csv?' + urlencode({
            's': symbol,
            # start_date month, zero indexed
            'a': start_date.month - 1,
            # start_date day
            'b': start_date.day,
            # start_date year
            'c': start_date.year,
            # end_date month, zero indexed
            'd': end_date.month - 1,
            # end_date day
            'e': end_date.day,
            # end_date year
            'f': end_date.year,
            # daily frequency
            'g': 'd',
        })
    ) 
Example #15
Source File: rpnet.py    From script.module.urlresolver with GNU General Public License v2.0 6 votes vote down vote up
def get_media_url(self, host, media_id):
        username = self.get_setting('username')
        password = self.get_setting('password')
        url = 'https://premium.rpnet.biz/client_api.php'
        query = urllib_parse.urlencode({'username': username, 'password': password, 'action': 'generate', 'links': media_id})
        url = url + '?' + query
        response = self.net.http_GET(url).content
        response = json.loads(response)
        if 'links' in response and response['links']:
            link = response['links'][0]
            if 'generated' in link:
                return link['generated']
            elif 'error' in link:
                raise ResolverError(link['error'])
        else:
            msg = 'No Link Returned'
            if 'error' in response and response['error']:
                msg += ': %s' % (response['error'][0])
            raise ResolverError(msg) 
Example #16
Source File: megadebrid.py    From script.module.urlresolver with GNU General Public License v2.0 6 votes vote down vote up
def login(self):
        try:
            common.logger.log('Mega-debrid - Logging In')
            username = self.get_setting('username')
            password = self.get_setting('password')
            if username and password:
                url = self.base_url + '?' + urllib_parse.urlencode({'action': 'connectUser', 'login': username, 'password': password})
                html = self.net.http_GET(url, headers=self.headers).content
                js_data = json.loads(html)
                if js_data.get('response_code') == 'ok':
                    self.token = js_data['token']
                    return True
                else:
                    msg = js_data.get('response_text', 'Unknown Error')
            else:
                msg = 'No Username/Password'
        except Exception as e:
            msg = str(e)

        raise ResolverError('MD Login Failed: %s' % (msg)) 
Example #17
Source File: show.py    From treadmill with Apache License 2.0 6 votes vote down vote up
def _get_state(apis, match=None, finished=False, partition=None):
    """Get cell state."""
    url = '/state/'

    query = {}
    if match:
        query['match'] = match
    if finished:
        query['finished'] = 'true'
    if partition:
        query['partition'] = partition

    if query:
        url += '?' + urllib_parse.urlencode(query)

    response = restclient.get(apis, url)
    return response.json() 
Example #18
Source File: megadebrid.py    From script.module.urlresolver with GNU General Public License v2.0 6 votes vote down vote up
def get_media_url(self, host, media_id):
        common.logger.log('in get_media_url %s : %s' % (host, media_id))
        if self.token is None:
            raise ResolverError('No MD Token Available')

        url = self.base_url + '?' + urllib_parse.urlencode({'action': 'getLink', 'token': self.token})
        data = {'link': media_id}
        html = self.net.http_POST(url, form_data=data, headers=self.headers).content
        js_data = json.loads(html)
        if js_data.get('response_code') == 'ok':
            if 'debridLink' in js_data:
                stream_url = js_data['debridLink'].strip('"')
                if stream_url.startswith('http'):
                    return stream_url
                else:
                    msg = 'MD Unusable Link: %s' % (stream_url)
            else:
                msg = 'MD No Link'
        else:
            msg = js_data.get('response_text', 'Unknown MD Error during resolve')

        logger.log_warning(msg)
        if isinstance(msg, six.text_type) and six.PY2:
            msg = msg.encode('utf-8')
        raise ResolverError(msg) 
Example #19
Source File: premiumize_me.py    From script.module.urlresolver with GNU General Public License v2.0 6 votes vote down vote up
def __direct_dl(self, media_id, torrent=False):
        try:
            data = urllib_parse.urlencode({'src': media_id})
            response = self.net.http_POST(direct_dl_path, form_data=data, headers=self.headers).content
            result = json.loads(response)
            if 'status' in result:
                if result.get('status') == 'success':
                    if torrent:
                        _videos = [(int(item.get('size')), item.get('link')) for item in result.get("content")
                                   if any(item.get('path').lower().endswith(x)
                                          for x in FORMATS)]
                        try:
                            return max(_videos)[1]
                        except ValueError:
                            raise ResolverError('Failed to locate largest video file')
                    else:
                        return result.get('location', None)
                else:
                    raise ResolverError('Link Not Found: Error Code: %s' % result.get('status'))
            else:
                raise ResolverError('Unexpected Response Received')
        except:
            pass

        return None 
Example #20
Source File: __init__.py    From treadmill with Apache License 2.0 6 votes vote down vote up
def fetch_report(report_type, match=None, partition=None):
    """Fetch a report of the given type and return it as a DataFrame."""
    api_urls = context.GLOBAL.cell_api()
    path = '/scheduler/{}'.format(report_type)

    query = {}
    if match:
        query['match'] = match
    if partition:
        query['partition'] = partition

    if query:
        path += '?' + urllib_parse.urlencode(query)

    response = restclient.get(api_urls, path).json()
    return pd.DataFrame(response['data'], columns=response['columns']) 
Example #21
Source File: soundcloud.py    From Dailyfresh-B2C with Apache License 2.0 6 votes vote down vote up
def auth_url(self):
        """Return redirect url"""
        state = None
        if self.STATE_PARAMETER or self.REDIRECT_STATE:
            # Store state in session for further request validation. The state
            # value is passed as state parameter (as specified in OAuth2 spec),
            # but also added to redirect_uri, that way we can still verify the
            # request if the provider doesn't implement the state parameter.
            # Reuse token if any.
            name = self.name + '_state'
            state = self.strategy.session_get(name) or self.state_token()
            self.strategy.session_set(name, state)

        params = self.auth_params(state)
        params.update(self.get_scope_argument())
        params.update(self.auth_extra_arguments())
        return self.AUTHORIZATION_URL + '?' + urlencode(params) 
Example #22
Source File: test_saml.py    From Dailyfresh-B2C with Apache License 2.0 6 votes vote down vote up
def modify_start_url(self, start_url):
        """
        Given a SAML redirect URL, parse it and change the ID to
        a consistent value, so the request is always identical.
        """
        # Parse the SAML Request URL to get the XML being sent to TestShib
        url_parts = urlparse(start_url)
        query = dict((k, v[0]) for (k, v) in
                     parse_qs(url_parts.query).items())
        xml = OneLogin_Saml2_Utils.decode_base64_and_inflate(
            query['SAMLRequest']
        )
        # Modify the XML:
        xml = xml.decode()
        xml, changed = re.subn(r'ID="[^"]+"', 'ID="TEST_ID"', xml)
        self.assertEqual(changed, 1)
        # Update the URL to use the modified query string:
        query['SAMLRequest'] = OneLogin_Saml2_Utils.deflate_and_base64_encode(
            xml
        )
        url_parts = list(url_parts)
        url_parts[4] = urlencode(query)
        return urlunparse(url_parts) 
Example #23
Source File: registration_sensor.py    From st2incubator with Apache License 2.0 5 votes vote down vote up
def _get_api_registrations(self, params):
        data = urllib_parse.urlencode(params)
        headers = {}
        headers['Content-Type'] = 'application/x-www-form-urlencoded'

        response = None
        attempts = 0
        while attempts < self.retries:
            try:
                response = requests.request(
                    method='GET',
                    url=self.url,
                    headers=headers,
                    timeout=self.timeout,
                    params=data)
                self.logger.debug('Got repsonse: %s.', response.json())
                break
            except Exception:
                msg = 'Unable to connect to registrations API.'
                self.logger.exception(msg)
                attempts += 1
                eventlet.sleep(self.retry_delay)

        if not response:
            raise Exception('Failed to connect to TypeForm API.')

        if response.status_code != httplib.OK:
            failure_reason = ('Failed to retrieve registrations: %s \
                (status code: %s)' % (response.text, response.status_code))
            self.logger.error(failure_reason)
            raise Exception(failure_reason)

        return response.json() 
Example #24
Source File: base_api_test.py    From apitools with Apache License 2.0 5 votes vote down vote up
def testQueryBytesRequest(self):
        method_config = base_api.ApiMethodInfo(
            request_type_name='SimpleMessage', query_params=['bytes_field'])
        service = FakeService()
        non_unicode_message = b''.join((six.int2byte(100),
                                        six.int2byte(200)))
        request = SimpleMessage(bytes_field=non_unicode_message)
        global_params = StandardQueryParameters()
        http_request = service.PrepareHttpRequest(method_config, request,
                                                  global_params=global_params)
        want = urllib_parse.urlencode({
            'bytes_field': base64.urlsafe_b64encode(non_unicode_message),
        })
        self.assertIn(want, http_request.url) 
Example #25
Source File: multi_cell_monitor.py    From treadmill with Apache License 2.0 5 votes vote down vote up
def _count(cell, appname):
    """Get number of instances scheduled/running on the cell."""
    try:
        ctx = context.Context()
        ctx.cell = cell
        ctx.dns_domain = context.GLOBAL.dns_domain

        stateapi = ctx.state_api()
        url = '/state/?' + urllib_parse.urlencode([('match', appname)])

        response = restclient.get(stateapi, url)
        state = response.json()

        for instance in state:
            _LOGGER.info('cell: %s - %s %s %s', cell,
                         instance['name'],
                         instance['state'],
                         instance['host'])

        return len([instance for instance in state
                    if instance['state'] == 'running'])

    except Exception:  # pylint: disable=W0703
        _LOGGER.exception('Unable to get instance count for cell %s, app: %s',
                          cell, appname)
        return 0 
Example #26
Source File: configure.py    From treadmill with Apache License 2.0 5 votes vote down vote up
def _list(apis, match):
    """List configured apps."""
    url = _APP_REST_PATH

    query = {'match': match}
    url += '?' + urllib_parse.urlencode(query)

    response = restclient.get(apis, url, timeout=_LIST_TIMEOUT)
    cli.out(_FORMATTER(response.json())) 
Example #27
Source File: base_api_test.py    From apitools with Apache License 2.0 5 votes vote down vote up
def testQueryBytesGlobalParams(self):
        method_config = base_api.ApiMethodInfo(
            request_type_name='SimpleMessage', query_params=['bytes_field'])
        service = FakeService()
        non_unicode_message = b''.join((six.int2byte(100),
                                        six.int2byte(200)))
        request = SimpleMessage()
        global_params = StandardQueryParameters(
            nextPageToken=non_unicode_message)
        http_request = service.PrepareHttpRequest(method_config, request,
                                                  global_params=global_params)
        want = urllib_parse.urlencode({
            'nextPageToken': base64.urlsafe_b64encode(non_unicode_message),
        })
        self.assertIn(want, http_request.url) 
Example #28
Source File: salesforce.py    From Dailyfresh-B2C with Apache License 2.0 5 votes vote down vote up
def user_data(self, access_token, *args, **kwargs):
        """Loads user data from service"""
        user_id_url = kwargs.get('response').get('id')
        url = user_id_url + '?' + urlencode({'access_token': access_token})
        try:
            return self.get_json(url)
        except ValueError:
            return None 
Example #29
Source File: oauth.py    From Dailyfresh-B2C with Apache License 2.0 5 votes vote down vote up
def auth_url(self):
        """Return redirect url"""
        state = self.get_or_create_state()
        params = self.auth_params(state)
        params.update(self.get_scope_argument())
        params.update(self.auth_extra_arguments())
        params = urlencode(params)
        if not self.REDIRECT_STATE:
            # redirect_uri matching is strictly enforced, so match the
            # providers value exactly.
            params = unquote(params)
        return '{0}?{1}'.format(self.authorization_url(), params) 
Example #30
Source File: oauth.py    From Dailyfresh-B2C with Apache License 2.0 5 votes vote down vote up
def oauth_authorization_request(self, token):
        """Generate OAuth request to authorize token."""
        if not isinstance(token, dict):
            token = parse_qs(token)
        params = self.auth_extra_arguments() or {}
        params.update(self.get_scope_argument())
        params[self.OAUTH_TOKEN_PARAMETER_NAME] = token.get(
            self.OAUTH_TOKEN_PARAMETER_NAME
        )
        state = self.get_or_create_state()
        params[self.REDIRECT_URI_PARAMETER_NAME] = self.get_redirect_uri(state)
        return '{0}?{1}'.format(self.authorization_url(), urlencode(params))