CartoDB / carto-python

CARTO Python client
https://carto.com
BSD 3-Clause "New" or "Revised" License
154 stars 62 forks source link

feature request: add `APIAuthClient.is_valid()` method #69

Closed andy-esch closed 6 years ago

andy-esch commented 6 years ago

Adding an .is_valid() method would be pretty useful for establishing if an application is good-to-go before starting to perform operations. I suppose this could be pulled off a bare-bones API request, but it would be useful to have a purpose-built method for doing this instead.

alrocar commented 6 years ago

Hi Andy,

sorry for the late response.

The FR seems good to me :) I'll take a look ASAP

andy-esch commented 6 years ago

I ended up doing my own version in cartoframes:

def _is_authenticated(self):
    """Checks if credentials allow for authenticated carto access"""
    try:
        self.sql_client.send(
            'select * from information_schema.tables limit 0')
    except CartoException as err:
        raise CartoException('Cannot authenticate user `{0}`. Check '
                             'credentials ({1}).'.format(
                                 self.creds.username(),
err))

I'm sure there's a better way to check authentication, but that's method seems like an ok first pass. And I think the carto python package is a more natural place for this functionality.

alrocar commented 6 years ago

Since you have a temporary solution in place, I'd wait till the new Auth API to see what implications it has with the SDK and so on.

So leaving this open at the moment.

Thanks!