Returns the path and query string portion of the request URL, first adding any necessary parameters. :param path: The path portion of the URL. :type path: string :param params: URL parameters. :type params: dict or list of key/value tuples :rtype: s
(self, path, params, accepts_clientid)
| 370 | body.get("error_message")) |
| 371 | |
| 372 | def _generate_auth_url(self, path, params, accepts_clientid): |
| 373 | """Returns the path and query string portion of the request URL, first |
| 374 | adding any necessary parameters. |
| 375 | |
| 376 | :param path: The path portion of the URL. |
| 377 | :type path: string |
| 378 | |
| 379 | :param params: URL parameters. |
| 380 | :type params: dict or list of key/value tuples |
| 381 | |
| 382 | :rtype: string |
| 383 | |
| 384 | """ |
| 385 | # Deterministic ordering through sorting by key. |
| 386 | # Useful for tests, and in the future, any caching. |
| 387 | extra_params = getattr(self, "_extra_params", None) or {} |
| 388 | if type(params) is dict: |
| 389 | params = sorted(dict(extra_params, **params).items()) |
| 390 | else: |
| 391 | params = sorted(extra_params.items()) + params[:] # Take a copy. |
| 392 | |
| 393 | if accepts_clientid and self.client_id and self.client_secret: |
| 394 | if self.channel: |
| 395 | params.append(("channel", self.channel)) |
| 396 | params.append(("client", self.client_id)) |
| 397 | |
| 398 | path = "?".join([path, urlencode_params(params)]) |
| 399 | sig = sign_hmac(self.client_secret, path) |
| 400 | return path + "&signature=" + sig |
| 401 | |
| 402 | if self.key: |
| 403 | params.append(("key", self.key)) |
| 404 | return path + "?" + urlencode_params(params) |
| 405 | |
| 406 | raise ValueError("Must provide API key for this API. It does not accept " |
| 407 | "enterprise credentials.") |
| 408 | |
| 409 | |
| 410 | from googlemaps.directions import directions |