discord-oauth2.py


Namediscord-oauth2.py JSON
Version 1.2.1 PyPI version JSON
download
home_pagehttps://github.com/TreeBen77/discordoauth2
SummaryUse Discord's OAuth2 effortlessly! Turns the auth code to a access token and the access token into scope infomation.
upload_time2023-05-27 09:01:03
maintainer
docs_urlNone
authorTreeBen77
requires_python>=3.8
licenseMIT
keywords flask oauth2 discord discord-api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # DiscordOAuth2.py
Use Discord's OAuth2 effortlessly! Turns the auth code to a access token and the access token into scope infomation.

### Useful Links
Discord Server: https://discord.gg/DJ9xbbZAP5

Documentation is coming soon, don't worry.

## Quickstart
### Installing
I've finally published the library to PyPi! So now you can use pip.
```
pip install discord-oauth2.py
```
### Example With Flask
Don't forget to replace all the client information with your application's own information. You can leave bot token empty if your not adding members to guilds.
```py
import discordoauth2
from flask import Flask, request

client = discordoauth2.Client(849930878276993044, secret="very-secret-code",
redirect="https://findingfakeurlsisprettyhard.tv/oauth2", bot_token="bot-token-only-required-for-guild-joining-or-updating-linked-roles-metadata")
app = Flask(__name__)

client.update_linked_roles_metadata([
    {
        "type": 2,
        "key": "level",
        "name": "Level",
        "description": "The level the user is on"
    },
    {
        "type": 7,
        "key": "supporter",
        "name": "Supporter",
        "description": "Spent money to help the game"
    }
])

@app.route('/')
def main():
  return redirect(client.generate_uri(scope=["identify", "connections", "guilds", "role_connections.write"]))

@app.route("/oauth2")
def oauth2():
    code = request.args.get("code")

    access = client.exchange_code(code)

    access.update_metadata("Platform Name", "Username",  level=69, supporter=True)

    identify = access.fetch_identify()
    connections = access.fetch_connections()
    guilds = access.fetch_guilds()

    return f"""{identify}<br><br>{connections}<br><br>{guilds}"""

app.run("0.0.0.0", 8080)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/TreeBen77/discordoauth2",
    "name": "discord-oauth2.py",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "flask,oauth2,discord,discord-api",
    "author": "TreeBen77",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/50/3a/adc2ddbf59fa5929147d9a52565f461b31248d71f7618b516d74942de7af/discord-oauth2.py-1.2.1.tar.gz",
    "platform": null,
    "description": "# DiscordOAuth2.py\nUse Discord's OAuth2 effortlessly! Turns the auth code to a access token and the access token into scope infomation.\n\n### Useful Links\nDiscord Server: https://discord.gg/DJ9xbbZAP5\n\nDocumentation is coming soon, don't worry.\n\n## Quickstart\n### Installing\nI've finally published the library to PyPi! So now you can use pip.\n```\npip install discord-oauth2.py\n```\n### Example With Flask\nDon't forget to replace all the client information with your application's own information. You can leave bot token empty if your not adding members to guilds.\n```py\nimport discordoauth2\nfrom flask import Flask, request\n\nclient = discordoauth2.Client(849930878276993044, secret=\"very-secret-code\",\nredirect=\"https://findingfakeurlsisprettyhard.tv/oauth2\", bot_token=\"bot-token-only-required-for-guild-joining-or-updating-linked-roles-metadata\")\napp = Flask(__name__)\n\nclient.update_linked_roles_metadata([\n    {\n        \"type\": 2,\n        \"key\": \"level\",\n        \"name\": \"Level\",\n        \"description\": \"The level the user is on\"\n    },\n    {\n        \"type\": 7,\n        \"key\": \"supporter\",\n        \"name\": \"Supporter\",\n        \"description\": \"Spent money to help the game\"\n    }\n])\n\n@app.route('/')\ndef main():\n  return redirect(client.generate_uri(scope=[\"identify\", \"connections\", \"guilds\", \"role_connections.write\"]))\n\n@app.route(\"/oauth2\")\ndef oauth2():\n    code = request.args.get(\"code\")\n\n    access = client.exchange_code(code)\n\n    access.update_metadata(\"Platform Name\", \"Username\",  level=69, supporter=True)\n\n    identify = access.fetch_identify()\n    connections = access.fetch_connections()\n    guilds = access.fetch_guilds()\n\n    return f\"\"\"{identify}<br><br>{connections}<br><br>{guilds}\"\"\"\n\napp.run(\"0.0.0.0\", 8080)\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Use Discord's OAuth2 effortlessly! Turns the auth code to a access token and the access token into scope infomation.",
    "version": "1.2.1",
    "project_urls": {
        "Homepage": "https://github.com/TreeBen77/discordoauth2"
    },
    "split_keywords": [
        "flask",
        "oauth2",
        "discord",
        "discord-api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0058dfd0e31b253e4bd7180376018ce2410e221a644568d13550d24fae91817f",
                "md5": "a53d3adec8d6b724fdf3dd94d4df2c1a",
                "sha256": "5d89fe690e9c9d81e127be4492239f7e38a2e8139afd69a31e84afdccd30f9b3"
            },
            "downloads": -1,
            "filename": "discord_oauth2.py-1.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a53d3adec8d6b724fdf3dd94d4df2c1a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 6478,
            "upload_time": "2023-05-27T09:01:01",
            "upload_time_iso_8601": "2023-05-27T09:01:01.962264Z",
            "url": "https://files.pythonhosted.org/packages/00/58/dfd0e31b253e4bd7180376018ce2410e221a644568d13550d24fae91817f/discord_oauth2.py-1.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "503aadc2ddbf59fa5929147d9a52565f461b31248d71f7618b516d74942de7af",
                "md5": "57be2b9e9010d02036085e7725c75ecf",
                "sha256": "3703fdbcec5a526a8160e8f39eee79163eea29a7aab2c92df8c2146daf542a35"
            },
            "downloads": -1,
            "filename": "discord-oauth2.py-1.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "57be2b9e9010d02036085e7725c75ecf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 6190,
            "upload_time": "2023-05-27T09:01:03",
            "upload_time_iso_8601": "2023-05-27T09:01:03.414497Z",
            "url": "https://files.pythonhosted.org/packages/50/3a/adc2ddbf59fa5929147d9a52565f461b31248d71f7618b516d74942de7af/discord-oauth2.py-1.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-27 09:01:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "TreeBen77",
    "github_project": "discordoauth2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "discord-oauth2.py"
}
        
Elapsed time: 0.10018s