Exception: Error retrieving a Domo API Access Token: "status":401,"Unauthorized","path":"/oauth/toke

Hello, I'm using Python SDK to create a new DataSet in Domo.

I use client id and secret, but getting the error above.

If I do cURL-I get the access-token, all works good .If I use access-token in the script- I get this:

ConnectionError: HTTPSConnectionPool(host='api_host', port=443): Max retries exceeded with url: /oauth/token?grant_type=client_credentials (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f0711397ee0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))

I'm wondering if I need to ask the access-token from an Admin

Answers

  • Looks like you're not passing in the domain with the URL correctly. Without seeing your code I can't tell you exactly but look at where you're specifying which instance / domain you're using to connect to.

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Hello, @GrantSmith . Thank you for your reply. Here is the code:

    from pydomo import Domo

    from pydomo.datasets import DataSetRequest, Schema, Column, ColumnType, Policy

    from pydomo.datasets import PolicyFilter, FilterOperator, PolicyType, Sorting

    client_id="xxxx"

    secret= "xxxx"

    domo = Domo('client-id','secret', api_host='api.domo.com')


    domo.logger.info("\n**** Domo API - DataSet Examples ****\n")

    datasets = domo.datasets

    # Define a DataSet Schema

    dsr = DataSetRequest()

    dsr.name = 'Test'

    dsr.description = 'First interaction'

    dsr.schema = Schema([Column(ColumnType.STRING, 'BMaaS')])


    # Create a DataSet with the given Schema

    dataset = datasets.create(dsr)

    domo.logger.info("Created DataSet " + dataset['id'])


    # Get a DataSets's metadata

    retrieved_dataset = datasets.get(dataset['id'])

    domo.logger.info("Retrieved DataSet " + retrieved_dataset['id'])


    # Import Data from a file

    csv_file_path = './some.csv'

    datasets.data_import_from_file(dataset['id'], csv_file_path)

    domo.logger.info("Uploaded data from a file to DataSet {}".format(dataset['id']))

  • If I run it with my company api-host(rakuten-du.domo.com) , I'm getting this:

    Traceback (most recent call last):

     File "/home/gala/.local/lib/python3.10/site-packages/requests/models.py", line 971, in json

      return complexjson.loads(self.text, **kwargs)

     File "/usr/lib/python3.10/json/__init__.py", line 346, in loads

      return _default_decoder.decode(s)

     File "/usr/lib/python3.10/json/decoder.py", line 337, in decode

      obj, end = self.raw_decode(s, idx=_w(s, 0).end())

     File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode

      raise JSONDecodeError("Expecting value", s, err.value) from None

    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

  • I found the mistake. I wrapped variables in brackets😂