-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
37 lines (32 loc) · 1.07 KB
/
Copy pathserver.py
File metadata and controls
37 lines (32 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
from flask import Flask, render_template, request
import requests
from dotenv import load_dotenv
load_dotenv()
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/about")
def about():
return render_template("about.html")
@app.route("/callback")
def callback():
code = request.args.get("code")
token = requests.post("https://slack.com/api/oauth.v2.access", data={
"client_id": os.environ.get("CLIENT_ID"),
"client_secret": os.environ.get("CLIENT_SECRET"),
"code": code,
"redirect_uri": os.environ.get("REDIRECT_URI")
})
data = token.json()
token = data["authed_user"]["access_token"]
requests.post("https://slack.com/api/users.profile.set",
headers={"Authorization": "Bearer " + token},
json={"profile": {
"status_text": "Distinguished Blåhaj member // Join The Blåhaj at blahaj.numycode.dev",
"status_emoji": ":blobhaj_party:",
"status_expiration": 0
}}
)
return render_template("callback.html")