Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

fix get_current_user_connections() #31

@watercatuwu

Description

@watercatuwu

The access code is correct
and I already select connections scope option in Discord Oauth2 URL

I can run get_current_user() but can't run get_current_user_connections()

Here is my code

from config import TOKEN, CLIENT_SECRET, REDIRECT_URI, OAUTH_URL
from flask import Flask, render_template, request
from zenora import APIClient

app = Flask(__name__)
client = APIClient(TOKEN, client_secret = CLIENT_SECRET)

@app.route("/")
def main():
    return render_template("index.html", oauthurl = OAUTH_URL)

@app.route("/oauth/callback")
def callback():
    code = request.args["code"]
    oauth_response = client.oauth.get_access_token(code, REDIRECT_URI)
    access_token = oauth_response.access_token
    bearer_client = APIClient(access_token, bearer = True)
    connections = bearer_client.users.get_current_user_connections() # <=
    return str(connections)

if __name__ == "__main__":
    app.run(port=8080)

At connections = bearer_client.users.get_current_user_connections()
the connection object returned None

File "/workspaces/discord-oauth/main.py", line 18, in callback
    connections = bearer_client.users.get_current_user_connections()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.12/site-packages/zenora/impl/userapi.py", line 93, in get_current_user_connections
    return_data.append(deserialize_model(Connection, x))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.12/site-packages/zenora/deserializers.py", line 57, in deserialize_model
    return cls(**data)
           ^^^^^^^^^^^
  File "<attrs generated init zenora.models.connection.Connection>", line 6, in __init__
    self.integrations = __attr_converter_integrations(integrations)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.12/site-packages/zenora/deserializers.py", line 65, in deserialize_server_integration
    for x in payload:
TypeError: 'NoneType' object is not iterable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions