-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_url.py
More file actions
executable file
·31 lines (27 loc) · 1.06 KB
/
gen_url.py
File metadata and controls
executable file
·31 lines (27 loc) · 1.06 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
import base64,hashlib,os
def generateRandom(length):
random_bytes = os.urandom(length)
return base64.urlsafe_b64encode(random_bytes).rstrip(b'=').decode('utf-8')
def calculateChallenge(codeVerifier):
hash_object = hashlib.sha256(codeVerifier.encode('utf-8'))
codeChallenge = base64.urlsafe_b64encode(hash_object.digest()).rstrip(b'=').decode('utf-8')
return codeChallenge
def getNSOLogin():
temp = generateRandom(32)
params = {
'state': generateRandom(36),
'redirect_uri': 'npf71b963c1b7b6d119://auth',
'client_id' : '71b963c1b7b6d119',
'scope': 'openid+user+user.birthday+user.mii+user.screenName',
'response_type': 'session_token_code',
'session_token_code_challenge': calculateChallenge(temp),
'session_token_code_challenge_method': 'S256',
'theme': 'login_form'
}
query_string = ""
for key,value in params.items():
query_string += f'{key}={value}&'
return 'https://accounts.nintendo.com/connect/1.0.0/authorize?' + query_string, temp
if __name__ == "__main__":
loginURL = getNSOLogin()
print(loginURL)