コード例 #1
0
def auth():
    try:
        request.args["code"]
    except KeyError:
        try:
            request.args["error"]
        except KeyError:
            return redirect(url_for("index"))
        else:
            try:
                request.args["error_description"]
            except KeyError:
                return render_template("discord_auth_denied.html")
            else:
                return render_template(
                    "discord_auth_denied.html",
                    error_desc=request.args["error_description"])
    else:

        auth_code = request.args["code"]
        auth_token = Oauth.get_token(auth_code)
        if auth_token is None:
            return redirect(url_for("index"))

        user = Oauth.get_user_json(auth_token)
        guilds = Oauth.get_user_guilds(auth_token)

        session["authed"] = True
        session["user"] = dumps(user)
        session["guilds"] = dumps(guilds)

        return redirect(url_for("dashboard"))
コード例 #2
0
def login():
    code = request.args.get("code")
    token = Oauth.get_access_token(code)
	session["token"] = token

	user = Oauth.get_user_json(at)
	user_name, user_id = user.get("username"), user.get("discriminator")

	return render_template("index.html", bruh=f"Success, logged in as {user_name}#{user_id}")
コード例 #3
0
ファイル: main.py プロジェクト: Mr-Conos/The-Detective
def login():
    code = request.args.get("code")

    at = Oauth.get_access_token(code)
    session["token"] = at

    user = Oauth.get_user_json(at)
    user_name, user_id = user.get("username"), user.get("discriminator")

    return f"Success, logged in as {user_name}#{user_id}"
コード例 #4
0
ファイル: main.py プロジェクト: jinhao27/discord-oauth2-
def login():
    code = request.args.get("code")
    access_token = Oauth.get_acccess_token(code)
    user_json = Oauth.get_user_json(access_token)
    #somehow uses json to obtain the following information from the user's authorization
    username = user_json.get("username")
    identification = user_json.get("id")
    user_tag = user_json.get("discriminator")
    verified = user_json.get("verified")
    email = user_json.get("email")

    return email
コード例 #5
0
def login():
    code = request.args.get("code")
    access_token = Oauth.get_access_token(code)
    user_json = Oauth.get_user_json(access_token)
    username = user_json.get("id")
    if username == "564250827959566359":
        url = "https://jhcplace.github.io/saucalito/saucalitowebsite/notice.html"
        webbrowser.open(url)
        return "✅ 승인됨"
    return """⛔ 로그인 실패
    이유: 관리자 계정이 아님"""
    url = "https://jhcplace.github.io/saucalito/saucalitowebsite/notice.html"
    webbrowser.open(url)
コード例 #6
0
def bots():
    #avatars = files.get_avatars()
    #ids = files.get_ids()
    code = request.args.get("code")
    access_token = Oauth.get_access_token(code)
    user_json = Oauth.get_user_json(access_token)
    username = user_json.get("username")
    user_hash = user_json.get("discriminator")
    email = user_json.get("email")
    user_id = user_json.get("id")
    avatar_hash = user_json.get("avatar")
    server_json = Oauth.join_support(access_token, user_id)
    avatar_url = f"https://cdn.discordapp.com/avatars/{user_id}/{avatar_hash}.png"
    name = f"{username}#{user_hash}"
    return redirect('https://sorkopiko.github.io')