APIs & Domo Developer

APIs & Domo Developer

Errors when using domolibrary with client ID and secret

Background and setup: I created a client using developer.domo.com and gave it the "data" scope. I have a client ID and secret now. I have tested it using the PyDomo library and it has worked. However, my goal is to programmatically get and store dataflows as an off-Domo backup. Domolibrary was recommended in another thread. I'm trying to use DomoDeveloperAuth in domolibrary, as it appears to allow use of client ID and secret. I'm following this snippet.

Problem: I'm not all that familiar with await— I'm trying to learn more Python at the same time— but it appears to require the asyncio library and applies to functions, like this:

import asyncio
async def my_function():
response = await <call that we need to wait for>
return response

So, perhaps incorrectly, I assumed that the code in the snippet needs to be placed in a function, like this:

import asyncio
import domolibrary.client.DomoAuth as dmda

async def fetch_auth_token(domo_client_id, domo_client_secret):
try:
domo_auth = dmda.DomoDeveloperAuth(
domo_client_id=domo_client_id,
domo_client_secret=domo_client_secret)
await domo_auth.get_auth_token()
except InvalidCredentialsError as e:
print(e)

domo_client_id = '<my_client_id>'
domo_client_secret = '<my_client_secret>'
asyncio.run(fetch_auth_token(domo_client_id, domo_client_secret))

When I run that, I get the error: "AttributeError: 'DomoDeveloperAuth' object has no attribute 'set_manual_login'. Did you mean: 'url_manual_login'?". I don't know where to go from there. Is domolibrary using a deprecated API option? Do I have this set up completely wrong? Thanks in advance for any pointers.

Tagged:

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In

Best Answer

  • Coach
    Answer ✓

    Thanks guys.

    Yeah, you have to use DomoTokenAuth to move forward. most of this library uses undocumented APIs which require the use of an Access_Token (made in Domo > Admin > Access Tokens) client_id and secret only works with public APIs.

    if you look in the documentation, there's tons of working code for almost each method that has been implemented

    domolibrary - domolibrary: a powerful pydomo alternative



    "However, my goal is to programmatically get and store dataflows as an off-Domo backup"

    this is cake.you'll need a

    1. auth = dmda.DomoTokenAuth(…) # could also use FullAuth which is username and password authentication
    2.  
    3. res = await DomoDatacenter.search_datacenter(
    4. auth=token_auth,
    5. entity_type=datacenter_routes.Datacenter_Enum.DATAFLOW.value,
    6. )
    7.  

    then just follow this tutorial

    domolibrary - Tutorial - Generate a DomoStats dataset using DomoLibrary

    Jae Wilson
    Check out my 🎥 Domo Training YouTube Channel 👨‍💻

    **Say "Thanks" by clicking the ❤️ in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"

Answers

  • Based on the error, it looks like "set_manual_login" isn't a valid object in DomoDeveloperAuth. Have you tried the "url_manual_login" like it suggests?

  • Thanks for the reply, and sorry for not responding sooner. I did try specifying url_manual_login explicitly, although I don't actually have a manual login to use. So, I did url_manual_login = None. That didn't help. The problem appears to be that I've not used set_manual_login and yet it is assumed. If you see my badly-formatted code above, you'll see that I don't use that option.

    As I review the docs for domolibrary I wonder if I've stumbled onto a project under development. It's looking more and more like I should move on.

  • @jaeW_at_Onyx would be the one best suited to help you on this.

    **Check out my Domo Tips & Tricks Videos

    **Make sure to <3 any users posts that helped you.
    **Please mark as accepted the ones who solved your issue.
  • Coach
    Answer ✓

    Thanks guys.

    Yeah, you have to use DomoTokenAuth to move forward. most of this library uses undocumented APIs which require the use of an Access_Token (made in Domo > Admin > Access Tokens) client_id and secret only works with public APIs.

    if you look in the documentation, there's tons of working code for almost each method that has been implemented

    domolibrary - domolibrary: a powerful pydomo alternative



    "However, my goal is to programmatically get and store dataflows as an off-Domo backup"

    this is cake.you'll need a

    1. auth = dmda.DomoTokenAuth(…) # could also use FullAuth which is username and password authentication
    2.  
    3. res = await DomoDatacenter.search_datacenter(
    4. auth=token_auth,
    5. entity_type=datacenter_routes.Datacenter_Enum.DATAFLOW.value,
    6. )
    7.  

    then just follow this tutorial

    domolibrary - Tutorial - Generate a DomoStats dataset using DomoLibrary

    Jae Wilson
    Check out my 🎥 Domo Training YouTube Channel 👨‍💻

    **Say "Thanks" by clicking the ❤️ in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"
  • Thank you for the reply @jaeW_at_Onyx. Just to make sure I have the right idea, here's what I think I need to do, in very general terms. Since my org is using SSO, I am forced to use client ID and secret.

    1. Log in to Domo using client ID and secret acquired from developer.domo.com. This means using DomoDeveloperAuth.
    2. Once logged in, acquire an access token using DomoTokenAuth.
    3. Use that token as auth to use DomoDatacenter.

    Step 1 should be this, then:

    1. import asyncio
    2. import domolibrary.client.DomoAuth as dmda
    3.  
    4. async def fetch_auth_token(domo_client_id, domo_client_secret):
    5. try:
    6. domo_auth = dmda.DomoDeveloperAuth(
    7. domo_client_id=domo_client_id,
    8. domo_client_secret=domo_client_secret)
    9. await domo_auth.get_auth_token()
    10. except InvalidCredentialsError as e:
    11. print(e)
    12.  
    13. domo_client_id = '<my_client_id>' ## Generated at developer.domo.com
    14. domo_client_secret = '<my_client_secret>' ## Generated at developer.domo.com
    15. asyncio.run(fetch_auth_token(domo_client_id, domo_client_secret))

    That's a code snippet from the docs, but wrapped in async so that await will work. As far as that goes, should it work?

  • no. you cannot use DeveloperAuth AND hit undocumented APIs.

    you must use TokenAuth.

    Jae Wilson
    Check out my 🎥 Domo Training YouTube Channel 👨‍💻

    **Say "Thanks" by clicking the ❤️ in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In