Oh yes, I forgot I changed stuff up while trying to get any response.
This is the updated code now...
import json
import requests
from msal import ConfidentialClientApplication
client_id ="{client_id}"
client_secret = "{client_secret}"
tenant_id = "{tenant_id}"
msal_authority = "https://login.microsoftonline.com/" + tenant_id
msal_scope = ["https://graph.microsoft.com/.default"]
msal_app = ConfidentialClientApplication(
client_id = client_id,
client_credential = client_secret,
authority = msal_authority,
)
result = msal_app.acquire_token_silent(
scopes = msal_scope,
account = None,
)
if not result:
result = msal_app.acquire_token_for_client(scopes = msal_scope)
access_token = result["access_token"]
print access_token
#api_result = requests.get(
# msal_authority,
# headers={'Authorization': 'Bearer ' + access_token},
# timeout=30,
# )
#
headers = {
"Authorization":"Bearer " + access_token,
"Content-Type": "application/json",
}
response = requests.get(
url="https://graph.microsoft.com/v1.0/users",
headers=headers,
)
print response
# Copy access_token and specify the MS Graph API endpoint you want to call, e.g. 'https://graph.microsoft.com/v1.0/groups' to get all groups in your organization
##access_token = '{ACCESS TOKEN YOU ACQUIRED PREVIOUSLY}'
#url = 'https://graph.microsoft.com/v1.0/groups'
#headers = {
# 'Authorization': access_token
#}
#
## Make a GET request to the provided url, passing the access token in a header
#graph_result = requests.get(url=url, headers=headers)
#
## Print the results in a JSON format
#print(graph_result.json())
And this is the error I get with the example:
Java Traceback:
Traceback (most recent call last):
File "<input>", line 46, in <module>
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\api.py", line 69, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\sessions.py", line 605, in send
r.content
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\models.py", line 750, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\models.py", line 750, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\models.py", line 673, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\models.py", line 673, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\models.py", line 673, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\packages\urllib3\response.py", line 303, in stream
for line in self.read_chunked(amt, decode_content=decode_content):
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\packages\urllib3\response.py", line 451, in read_chunked
yield self._decode(chunk, decode_content=decode_content,
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\packages\urllib3\response.py", line 192, in _decode
data = self._decoder.decompress(data)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\packages\urllib3\response.py", line 192, in _decode
data = self._decoder.decompress(data)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\packages\urllib3\response.py", line 58, in decompress
return self._obj.decompress(data)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\zlib.py", line 228, in decompress
inflated = _get_inflate_data(self.inflater, max_length)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\zlib.py", line 291, in _get_inflate_data
l = inflater.inflate(buf)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\zlib.py", line 291, in _get_inflate_data
l = inflater.inflate(buf)
at java.base/java.util.zip.Inflater.ensureOpen(Unknown Source)
at java.base/java.util.zip.Inflater.inflate(Unknown Source)
at java.base/java.util.zip.Inflater.inflate(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.NullPointerException: java.lang.NullPointerException: Inflater has been closed
at org.python.core.Py.JavaError(Py.java:545)
at org.python.core.Py.JavaError(Py.java:536)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:192)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:208)
at org.python.core.PyObject.__call__(PyObject.java:477)
at org.python.core.PyObject.__call__(PyObject.java:481)
at org.python.core.PyMethod.__call__(PyMethod.java:141)
at zlib$py._get_inflate_data$15(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/zlib.py:303)
at zlib$py.call_function(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/zlib.py)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:150)
at org.python.core.PyFunction.__call__(PyFunction.java:426)
at zlib$py.decompress$11(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/zlib.py:247)
at zlib$py.call_function(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/zlib.py)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
at org.python.core.PyBaseCode.call(PyBaseCode.java:141)
at org.python.core.PyFunction.__call__(PyFunction.java:426)
at org.python.core.PyMethod.__call__(PyMethod.java:141)
at requests.packages.urllib3.response$py.decompress$8(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/packages/urllib3/response.py:58)
at requests.packages.urllib3.response$py.call_function(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/packages/urllib3/response.py)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:150)
at org.python.core.PyFunction.__call__(PyFunction.java:426)
at org.python.core.PyMethod.__call__(PyMethod.java:141)
at requests.packages.urllib3.response$py._decode$18(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/packages/urllib3/response.py:203)
at requests.packages.urllib3.response$py.call_function(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/packages/urllib3/response.py)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
at org.python.core.PyBaseCode.call(PyBaseCode.java:197)
at org.python.core.PyFunction.__call__(PyFunction.java:485)
at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:237)
at org.python.core.PyMethod.__call__(PyMethod.java:228)
at requests.packages.urllib3.response$py.read_chunked$32(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/packages/urllib3/response.py:466)
at requests.packages.urllib3.response$py.call_function(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/packages/urllib3/response.py)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyGenerator.__iternext__(PyGenerator.java:161)
at org.python.core.PyGenerator.__iternext__(PyGenerator.java:143)
at requests.packages.urllib3.response$py.stream$20(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/packages/urllib3/response.py:306)
at requests.packages.urllib3.response$py.call_function(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/packages/urllib3/response.py)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyGenerator.__iternext__(PyGenerator.java:161)
at org.python.core.PyGenerator.__iternext__(PyGenerator.java:143)
at requests.models$py.generate$41(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/models.py:689)
at requests.models$py.call_function(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/models.py)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyGenerator.__iternext__(PyGenerator.java:161)
at org.python.core.PyGenerator.__iternext__(PyGenerator.java:143)
at org.python.core.PySequence.fastSequence(PySequence.java:314)
at org.python.core.PyString.str_join(PyString.java:3271)
at org.python.core.PyString$str_join_exposer.__call__(Unknown Source)
at org.python.core.PyObject.__call__(PyObject.java:465)
at requests.models$py.content$43(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/models.py:758)
at requests.models$py.call_function(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/models.py)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:134)
at org.python.core.PyFunction.__call__(PyFunction.java:416)
at org.python.core.PyFunction.__call__(PyFunction.java:411)
at org.python.core.PyProperty.property___get__(PyProperty.java:82)
at org.python.core.PyProperty.__get__(PyProperty.java:71)
at org.python.core.PyObject.object___findattr__(PyObject.java:3766)
at org.python.core.Deriveds.__findattr_ex__(Deriveds.java:43)
at org.python.core.PyObjectDerived.__findattr_ex__(PyObjectDerived.java:1036)
at org.python.core.PyObject.__getattr__(PyObject.java:957)
at requests.sessions$py.send$21(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/sessions.py:607)
at requests.sessions$py.call_function(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/sessions.py)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
at org.python.core.PyBaseCode.call(PyBaseCode.java:197)
at org.python.core.PyFunction.__call__(PyFunction.java:485)
at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:237)
at org.python.core.PyMethod.__call__(PyMethod.java:228)
at org.python.core.PyMethod.__call__(PyMethod.java:223)
at org.python.core.PyObject._callextra(PyObject.java:589)
at requests.sessions$py.request$13(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/sessions.py:467)
at requests.sessions$py.call_function(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/sessions.py)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
at org.python.core.PyBaseCode.call(PyBaseCode.java:197)
at org.python.core.PyFunction.__call__(PyFunction.java:485)
at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:237)
at org.python.core.PyMethod.__call__(PyMethod.java:228)
at org.python.core.PyMethod.__call__(PyMethod.java:223)
at org.python.core.PyObject._callextra(PyObject.java:589)
at requests.api$py.request$1(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/api.py:55)
at requests.api$py.call_function(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/api.py)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
at org.python.core.PyFunction.function___call__(PyFunction.java:474)
at org.python.core.PyFunction.__call__(PyFunction.java:469)
at org.python.core.PyFunction.__call__(PyFunction.java:464)
at org.python.core.PyObject._callextra(PyObject.java:589)
at requests.api$py.get$2(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/api.py:69)
at requests.api$py.call_function(C:/Users/bmeyers/.ignition/cache/gwlocalhost_8088/C0/pylib/requests/api.py)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
at org.python.core.PyFunction.function___call__(PyFunction.java:474)
at org.python.core.PyFunction.__call__(PyFunction.java:469)
at org.python.pycode._pyx17.f$0(<input>:51)
at org.python.pycode._pyx17.call_function(<input>)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1703)
at org.python.core.Py.exec(Py.java:1747)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:277)
at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:130)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:628)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:616)
at java.desktop/javax.swing.SwingWorker$1.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.desktop/javax.swing.SwingWorker.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Inflater has been closed
at java.base/java.util.zip.Inflater.ensureOpen(Unknown Source)
at java.base/java.util.zip.Inflater.inflate(Unknown Source)
at java.base/java.util.zip.Inflater.inflate(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
... 111 more
Traceback (most recent call last):
File "<input>", line 46, in <module>
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\api.py", line 69, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\sessions.py", line 605, in send
r.content
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\models.py", line 750, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\models.py", line 750, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\models.py", line 673, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\models.py", line 673, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\models.py", line 673, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\packages\urllib3\response.py", line 303, in stream
for line in self.read_chunked(amt, decode_content=decode_content):
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\packages\urllib3\response.py", line 451, in read_chunked
yield self._decode(chunk, decode_content=decode_content,
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\packages\urllib3\response.py", line 192, in _decode
data = self._decoder.decompress(data)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\packages\urllib3\response.py", line 192, in _decode
data = self._decoder.decompress(data)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\requests\packages\urllib3\response.py", line 58, in decompress
return self._obj.decompress(data)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\zlib.py", line 228, in decompress
inflated = _get_inflate_data(self.inflater, max_length)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\zlib.py", line 291, in _get_inflate_data
l = inflater.inflate(buf)
File "C:\Users\bmeyers\.ignition\cache\gwlocalhost_8088\C0\pylib\zlib.py", line 291, in _get_inflate_data
l = inflater.inflate(buf)
at java.base/java.util.zip.Inflater.ensureOpen(Unknown Source)
at java.base/java.util.zip.Inflater.inflate(Unknown Source)
at java.base/java.util.zip.Inflater.inflate(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.NullPointerException: java.lang.NullPointerException: Inflater has been closed
It was mad about something with zlib.py and that is when I started looking into older versions of the libraries and then things just got worse so I posted here looking for any advice/input.