Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporter APS Authentication #1001

Merged
merged 11 commits into from
Jul 9, 2024
Merged

Conversation

PepperLola
Copy link
Contributor

@PepperLola PepperLola commented Jun 27, 2024

Changes:

  • Palette to get authorization code for Autodesk account
  • Fetches code and refreshes automatically once expired
  • Shows first name in a new tab in the main exporter panel (temporary)

Testing:

  • Make sure the server is running (same branch name as this pr)
  • Sign in with APS button
  • Check main panel to see if your name shows up in a third tab
  • Make sure login palette automatically closes after signing in
  • Make sure reopening palette prompts for login again
  • Make sure closing palette manually and reopening prompts for login again
    • Might have to enter email but not password to ensure that it's resetting

Warning

I haven't yet tested refreshing the token once it's expired. The web request works though and gets a different access token than before.

Important

This branch must be tested while running the server through the Docker container, because some authorization logic happens on the server side.

@PepperLola PepperLola self-assigned this Jun 27, 2024
@PepperLola PepperLola requested a review from a team as a code owner June 27, 2024 22:44
@PepperLola PepperLola requested review from a-crowell, azaleacolburn and BrandonPacewic and removed request for a team June 27, 2024 22:44
@autodesk-chorus
Copy link

Chorus detected one or more security issues with this pull request. See the Checks tab for more details.

As a reminder, please follow the secure code review process as part of the Secure Coding Non-Negotiable requirement.

@PepperLola PepperLola removed the request for review from a-crowell June 27, 2024 22:50
Copy link
Member

@BrandonPacewic BrandonPacewic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the following error upon attempt to open the APS panel.

image

Here is the log file:

2024-06-28 10:03:56,954 - synthesis.Toolbar.getNewPanel - DEBUG - Created Panel Synthesis_synthesis_tooltab in Toolbar ToolsTab
2024-06-28 10:03:56,972 - synthesis.HUI.HButton - INFO - Created Button SynthesisExporter_synthesis in Panel Synthesis_synthesis_tooltab
2024-06-28 10:03:56,989 - synthesis.HUI.HButton - INFO - Created Button APS_synthesis in Panel Synthesis_synthesis_tooltab
2024-06-28 10:04:19,260 - synthesis - ERROR - Command executed failed: Traceback (most recent call last):
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/http/client.py", line 975, in send
    self.connect()
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/http/client.py", line 941, in connect
    self.sock = self._create_connection(
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/socket.py", line 851, in create_connection
    raise exceptions[0]
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/socket.py", line 836, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/brandon/Documents/Repos/synthesis/exporter/SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py", line 32, in notify
    challenge = getCodeChallenge()
                ^^^^^^^^^^^^^^^^^^
  File "/Users/brandon/Documents/Repos/synthesis/exporter/SynthesisFusionAddin/src/APS/APS.py", line 64, in getCodeChallenge
    res = urllib.request.urlopen(endpoint)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/urllib/request.py", line 519, in open
    response = self._open(req, data)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/urllib/request.py", line 1377, in http_open
    return self.do_open(http.client.HTTPConnection, req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 61] Connection refused>

2024-06-28 10:07:02,016 - synthesis - ERROR - Command executed failed: Traceback (most recent call last):
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/http/client.py", line 975, in send
    self.connect()
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/http/client.py", line 941, in connect
    self.sock = self._create_connection(
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/socket.py", line 851, in create_connection
    raise exceptions[0]
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/socket.py", line 836, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/brandon/Documents/Repos/synthesis/exporter/SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py", line 32, in notify
    challenge = getCodeChallenge()
                ^^^^^^^^^^^^^^^^^^
  File "/Users/brandon/Documents/Repos/synthesis/exporter/SynthesisFusionAddin/src/APS/APS.py", line 64, in getCodeChallenge
    res = urllib.request.urlopen(endpoint)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/urllib/request.py", line 519, in open
    response = self._open(req, data)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/urllib/request.py", line 1377, in http_open
    return self.do_open(http.client.HTTPConnection, req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/brandon/Library/Application Support/Autodesk/webdeploy/production/6997599ab67b7e881f25c2311930a09bc5ac662f/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.11/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 61] Connection refused>

This was referenced Jun 28, 2024
Copy link
Member

@BrandonPacewic BrandonPacewic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work...

The security workflow is getting real mad at us with this one, not sure if there is anything we can do to fix that though.

@HunterBarclay
Copy link
Member

@PepperLola Something to note: I forgot to switch the server branch over so I ran into an issue. That being said, after getting the issue, there isn't any way for me to reset the aps login process without restarting the addin. Could we have to detect an error and then automatically reset?

@HunterBarclay
Copy link
Member

@PepperLola I get this page in the palette, and then nothing further:

image

@HunterBarclay
Copy link
Member

It does appear to successfully login, however.

image

delete unnecessary logs with sensitive data
only handle errors in the palette so it can delete/reset itself on error
…k/synthesis into jwrigh/1671/exporter-integration
@PepperLola PepperLola requested a review from HunterBarclay as a code owner July 3, 2024 21:45
Copy link
Contributor

@azaleacolburn azaleacolburn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I'm super late to the party, but everything worked for me.


def convertAuthToken(code: str):
global APS_AUTH
authUrl = f'http://localhost:3003/api/aps/code/?code={code}&redirect_uri={urllib.parse.quote_plus("http://localhost:3003/api/aps/exporter/")}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These will have to be changed to the actually URL eventually, right? A constant might be helpful for this.

@azaleacolburn azaleacolburn mentioned this pull request Jul 8, 2024
2 tasks
@HunterBarclay HunterBarclay merged commit 20c64a0 into dev Jul 9, 2024
11 of 12 checks passed
@HunterBarclay HunterBarclay deleted the jwrigh/1671/exporter-integration branch July 9, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants