Commit d6b3796 1 parent d92f226 commit d6b3796 Copy full SHA for d6b3796
File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ import untappd
2
+ import json
3
+ from http .server import BaseHTTPRequestHandler , HTTPServer
4
+ import re
5
+ import sys
6
+
7
+ creds = json .load (open ('.credentials.json' ))
8
+
9
+ client = untappd .Untappd (
10
+ client_id = creds ["client_id" ],
11
+ client_secret = creds ["client_secret" ],
12
+ redirect_url = 'http://localhost:8083' ,
13
+ user_agent = 'letmein'
14
+ )
15
+
16
+
17
+
18
+ hostName = "localhost"
19
+ serverPort = 8083
20
+
21
+ class MyServer (BaseHTTPRequestHandler ):
22
+ def do_GET (self ):
23
+ code = re .search ('code=(.*)' , self .path ).group (1 )
24
+ res = client .oauth .get_access_token (code )
25
+ creds ["user_token" ] = res
26
+ with open (".credentials.json" , "w" ) as fout :
27
+ print (json .dumps (creds ), file = fout )
28
+ sys .exit (0 )
29
+
30
+ webServer = HTTPServer ((hostName , serverPort ), MyServer )
31
+ print (client .oauth .get_auth_url ())
32
+ webServer .serve_forever ()
You can’t perform that action at this time.
0 commit comments