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

fix get_current_user_connections() #31

Open
watercatuwu opened this issue Apr 3, 2024 · 0 comments
Open

fix get_current_user_connections() #31

watercatuwu opened this issue Apr 3, 2024 · 0 comments

Comments

@watercatuwu
Copy link

watercatuwu commented Apr 3, 2024

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
@watercatuwu watercatuwu changed the title Help me to get current user connections fix get_current_user_connections() Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant