Coder Social home page Coder Social logo

Comments (5)

spencermaxfield avatar spencermaxfield commented on July 29, 2024

The metadata is stored alongside the response. I tested this out by calling duo_client.Admin#get_users and setting a breakpoint at the line you referenced. The data shape looks like:

{
	'metadata': {
		'total_objects': 12
	},
	'response': [{
		<list of users>
	}],
	'stat': 'OK'
}

If there's a particular method/endpoint you find is not working properly, please provide a reduction of the problem as a script that we can run as well so we can investigate. Thank you!

from duo_client_python.

wisebaldone avatar wisebaldone commented on July 29, 2024

Sorry for the delay

I was testing using the Trust Monitor event logs, I get a response like this:

{
  "response": {
    "events": [...],
    "metadata": { "next_offset": "1211416" }
  },
  "stat": "OK"
}

The docs for this endpoint seems to confirm as well, also tested the user's endpoint and can confirm is as you said. So the error seems to be that admin/v1/trust_monitor/events doesn't conform to the standard.

from duo_client_python.

spencermaxfield avatar spencermaxfield commented on July 29, 2024

@wisebaldone Thanks for this! I agree that the trust monitor response looks incorrect. Let me get in touch with the appropriate team and see what I can find out.

from duo_client_python.

spencermaxfield avatar spencermaxfield commented on July 29, 2024

@wisebaldone After investigating further, I've confirmed this is a bug (no surprise there). Unfortunately, there are other endpoints outside of Trust Monitor Events endpoint affected by this as well, so it's not as simple as "fix one bad endpoint." We're discussing this internally and will fix this, although I cannot give an estimate on exactly when yet.

In the meantime, if you're okay with making some code modifications to get things working, the following patch should do the trick (Fair warning - I didn't test this super thoroughly):

diff --git a/duo_client/client.py b/duo_client/client.py
index 7ed6b32..a2a1f1f 100644
--- a/duo_client/client.py
+++ b/duo_client/client.py
@@ -583,7 +583,13 @@ class Client(object):
             data = json.loads(data)
             if data['stat'] != 'OK':
                 raise_error('Received error response: %s' % data)
-            return (data['response'], data.get('metadata', {}))
+
+            response = data['response']
+            metadata = data.get('metadata', None)
+            if metadata is None:
+                metadata = response.get('metadata', {})
+
+            return response, metadata
         except (ValueError, KeyError, TypeError):
             raise_error('Received bad response: %s' % data)

from duo_client_python.

spencermaxfield avatar spencermaxfield commented on July 29, 2024

@wisebaldone This bug is fixed with PR #214, which is now on master and will be included in the next release. I'll leave this issue open for now in case you'd like to test the changes on master yourself before the release. I'll close the issue with the next release unless you test and encounter a problem.

Thank you!

from duo_client_python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.