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"))
def auth(self): from oauth import Oauth oauth = Oauth(self.configFileName) try: oauth.oauth() except: print('用户信息验证失败')
class PanelZero(wx.Panel): def __init__(self,parent): wx.Panel.__init__(self,parent=parent) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) link = HyperLinkCtrl(self,pos=(10,350)) self.consumer_key = 'your consumber key' self.consumer_secret = 'your consumber secret' self.url = "www.douban.com" self.request_token_path = "http://www.douban.com/service/auth/request_token" self.authorizationUrl = "http://www.douban.com/service/auth/authorize?oauth_token=" self.access_token_path = "http://www.douban.com/service/auth/access_token" self.client = Oauth(self.consumer_key,self.consumer_secret) self.client.get_request_token(self.url,self.request_token_path) authorizationUrl = self.client.get_authorizationUrl(self.authorizationUrl) #print authorizationUrl link.SetURL(authorizationUrl) if os.path.exists('./data/user.pickle'): link.SetLabel("已完成授权") else: link.SetLabel("去豆瓣授权") link.SetFont(wx.Font(15,wx.SWISS,wx.NORMAL,wx.NORMAL,False)) link.SetBackgroundColour("SKY BLUE") link.SetForegroundColour("white") link.SetVisited(Visited=False) button = wx.lib.buttons.GenButton(self,-1,"Login",pos=(100,220)) button.SetFont(wx.Font(20,wx.SWISS,wx.NORMAL,wx.BOLD,False)) button.SetBackgroundColour("SKY BLUE") button.SetForegroundColour("white") self.Bind(wx.EVT_BUTTON,self.OnClick,button) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) def OnEraseBackground(self, evt): """ Add a picture to the background """ dc = evt.GetDC() if not dc: dc = wx.ClientDC(self) rect = self.GetUpdateRegion().GetBox() dc.SetClippingRect(rect) dc.Clear() bmp = wx.Bitmap("./image/hzw.jpg") dc.DrawBitmap(bmp, 0, 0) def OnClick(self,event): if os.path.exists("./data/user.pickle"): pass else : access_token = self.client.get_access_token(self.url,self.access_token_path) with open('./data/user.pickle','wb') as f: userinfo = pickle.dump(access_token,f) self.Hide() self.GetParent().panel1 = PanelOne(self.GetParent()) self.GetParent().panel1.Fit() self.GetParent().panel1.SetBackgroundColour('white') self.GetParent().panel1.Show()
def auth(self): from oauth import Oauth oauth = Oauth(self.configFileName) try: oauth.oauth() except: print("用户信息验证失败")
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}")
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}"
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
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)
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')
def start_streaming(self): if self.agent_ids: def func(stream, user_ids): return stream.filter(follow=user_ids) user_ids, last_agent = [], None for agent in self.agent_ids: if agent['auth_user'] and agent['state'] != 'archive': last_agent = agent user_ids.append(agent['auth_user']) if user_ids: auth = Oauth(self.twitter_api_key, self.twitter_api_secret) auth.set_access_token(last_agent['twitter_access_token'], last_agent['twitter_access_token_secret']) stream = Stream(auth, self) self.streams_objs[self.id] = stream start_new_thread(func, (stream, user_ids)) return True
def __init__(self,parent): wx.Panel.__init__(self,parent=parent) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) link = HyperLinkCtrl(self,pos=(10,350)) self.consumer_key = 'your consumber key' self.consumer_secret = 'your consumber secret' self.url = "www.douban.com" self.request_token_path = "http://www.douban.com/service/auth/request_token" self.authorizationUrl = "http://www.douban.com/service/auth/authorize?oauth_token=" self.access_token_path = "http://www.douban.com/service/auth/access_token" self.client = Oauth(self.consumer_key,self.consumer_secret) self.client.get_request_token(self.url,self.request_token_path) authorizationUrl = self.client.get_authorizationUrl(self.authorizationUrl) #print authorizationUrl link.SetURL(authorizationUrl) if os.path.exists('./data/user.pickle'): link.SetLabel("已完成授权") else: link.SetLabel("去豆瓣授权") link.SetFont(wx.Font(15,wx.SWISS,wx.NORMAL,wx.NORMAL,False)) link.SetBackgroundColour("SKY BLUE") link.SetForegroundColour("white") link.SetVisited(Visited=False) button = wx.lib.buttons.GenButton(self,-1,"Login",pos=(100,220)) button.SetFont(wx.Font(20,wx.SWISS,wx.NORMAL,wx.BOLD,False)) button.SetBackgroundColour("SKY BLUE") button.SetForegroundColour("white") self.Bind(wx.EVT_BUTTON,self.OnClick,button) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
def start_streaming(self): if self.agent_ids: def func(stream, user_ids): return stream.filter(follow=user_ids) user_ids, last_agent = [], None for agent in self.agent_ids: if agent['auth_user'] and agent['state'] != 'archive': last_agent = agent user_ids.append(agent['auth_user']) if user_ids: auth = Oauth(self.twitter_api_key, self.twitter_api_secret) auth.set_access_token( last_agent['twitter_access_token'], last_agent['twitter_access_token_secret']) stream = Stream(auth, self) self.streams_objs[self.id] = stream start_new_thread(func, (stream, user_ids)) return True
OAUTH_URL = 'https://id.nctu.edu.tw' NCTU_APP_REDIRECT_URI = 'https://107songs.nctu.me/' NCTU_APP_CLIENT_ID = 'dFo3aTrp02yAzzHgaYNf90IUGe15ASgZfb6Wl2gb' NCTU_APP_CLIENT_SECRET = 'dV2NgLReGwmKyfBIGajbVAZCAr7puGyudu1ZianSaIMV441Lo4udlPXloItyQTCGN3aHapPDV4OzNfb91Z1Hfm1HSEQkK9yKLt3vwtUc7JczIeDB7Rfo3nVqVgEuDbTY' app = Flask(__name__, static_url_path='') app.secret_key = 'your super coll secrey key' app.config['JWT_ACCESS_TOKEN_EXPIRES'] = False jwt = JWTManager(app) SQLITE_DB_PATH = 'songs.db' SQLITE_DB_SCHEMA = 'create_db.sql' MEMBER_CSV_PATH = 'songs.csv' # make a oauth init nctu = Oauth(redirect_uri=NCTU_APP_REDIRECT_URI, client_id=NCTU_APP_CLIENT_ID, client_secret=NCTU_APP_CLIENT_SECRET) @app.route("/backend") def home(): # check if login if session.get('logged_in'): # get user profile return jsonify(nctu.get_profile()) writeLog('not login user try to login') return redirect('/login') @app.route('/analytics', methods=['GET']) @cross_origin()
from flask import Flask,request, render_template,redirect,session import requests from user import User import os from oauth import Oauth from marriagebot import Marriagebot app = Flask(__name__) app.secret_key = os.urandom(24) users = {} oauth = Oauth() ''' page the discord login redirects the user to when successfully logged in with discord ''' @app.route("/login",methods=['post','get']) def login(): code = request.args.get('code') if(code == None): return redirect("/") token = oauth.get_token(code) user_object = oauth.get_user_credentials(token) session["user_token"] = token users[token] = user_object return redirect("/colours") @app.route("/submit_colours",methods=['post','get']) def submit_colours():
from flask import Flask, render_template, session, redirect, request, url_for import pymongo from pymongo import MongoClient import sys import os from oauth import Oauth app = Flask(__name__) app.secret_key = os.urandom(24) cluster = pymongo.MongoClient("mongodb+srv://bebot:[email protected]/<dbname>?retryWrites=true&w=majority", maxPoolSize=50, connect=False) db = cluster["Bebot"] client = Oauth(app) @app.route('/') def index(): count = db["MemberCount"].find({}).sort('$natural', pymongo.ASCENDING) guild_count = count[count.count() - 1]["guild_count"] member_count = count[count.count() - 1]["member_count"] print(guild_count, file=sys.stderr) return render_template('index.html', guild_count=guild_count, member_count=member_count) @app.route('/features') def features(): return render_template('features.html') if __name__ == '__main__': app.run(debug=True)
def auth(): code = request.args.get("code") access_token = Oauth.get_access_token(code) user = Oauth.get_user_data(access_token) Oauth.insert_user_id(user.get("id")) return redirect("http://localhost:51883")
# Main function - program entry point if __name__ == '__main__': print("") print("INSTRUCTIONS:") print( "First, backup your blog. Blogger->Settings->Other->Import & back up") print( "Go to https://jamesoflol.github.io/photobucket-blogger-migratinator") print( "Under Step 3, click 'AUTHENTICATE WITH GOOGLE NOW'. Follow prompts to log in with the Google account you use for Blogger." ) auth_code = raw_input( "Paste the 'Authentication code' here, and press enter: (It'll start with something like 4/Y2_b...): " ).strip() oauth = Oauth(auth_code) print("Got access token: " + oauth.access_token) all_my_blogs = list_blogs() print("") print("Here's a list of your blogs: ") for index, blog in enumerate(all_my_blogs): print("- Blog number: {0}, url: {1}".format(index, blog['url'])) print("") blog_num = raw_input( "Type the number of the blog you want to work on: Default [0]: ") if blog_num: blog_num = int(blog_num) else: blog_num = 0