xyzspaces.auth module

This module provides HERE authentication via cookies for the Token API.

This get_auth_cookies() function simulates the login process on http://developer.here.com to obtain an access cookie for authenticating with certain RESTful APIs like the XYZ Token API.

This implementation is inspired by the Open Source HERE XYZ CLI: https://github.com/heremaps/here-cli/blob/master/src/sso.ts.

xyzspaces.auth.filter_cookies(cookies, prefix)[source]

Filter requests cookies with some given name prefix into a new dict.

Parameters
  • cookies (requests.cookies.RequestsCookieJar) – A requests cookies object.

  • prefix (str) – A prefix string to search in cookies.

Returns

A dict.

Return type

dict

Example:

Input:

<RequestsCookieJar[
    <Cookie locale=en-US for .here.com/>,
    <Cookie here_account=foobar for account.here.com/>,
    <Cookie here_account.sig=barfoo for account.here.com/>]
>

Output:

{'here_account': 'foobar', 'here_account.sig': 'barfoo'}
xyzspaces.auth.get_auth_cookies(username, password)[source]

Get authentication cookies from name and password of a HERE account.

Parameters
  • username (str) – Username for HERE account.

  • password (str) – Password for HERE account.

Returns

A dict.

Raises

AuthenticationError – If status_code for HTTP response returned by requests is not equal to 200.

Return type

dict