repl.it
@NihalAnand/

Google Sheets Login System (No Encryption)

Python

No description

fork
loading
Files
  • main.py
  • Python Test-32b5fbe50b83.json
  • Packager files
  • poetry.lock
  • pyproject.toml
  • requirements.txt
main.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import gspread
from oauth2client.service_account import ServiceAccountCredentials

scope = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']

credentials = ServiceAccountCredentials.from_json_keyfile_name('Python Test-32b5fbe50b83.json', scope)

gc = gspread.authorize(credentials)

wks = gc.open("Test For Python Integration").sheet1

def validatePass(p1, p2):
	if p1 == p2:
		return True

def next_available_row(worksheet):
    str_list = worksheet.col_values(1)
    return len(str_list)+1

def createAuth():
	global wks
	while True:
		user = input("Please enter a username ")
		passW = input("Please enter a password ")
		passW2 = input("Please enter your password again ")
		if validatePass(passW, passW2):
			try:
				wks.find(user)
			except:
				wks.resize(next_available_row(wks))
				wks.append_row([user, passW])
				print("Sign up successful.")
				break
			print("Username already exists. Please try again with a different username.")
		else:
			print("Your passwords didn't match. Please try again.")

def login():
	global wks
	while 1:
		user = input("Please enter your username ")
		passW = input("Please enter your password ")
		try:
			t1 = wks.find(user)
		except:
			print("Invalid username. Please try again or create an account.")
			continue
		if wks.cell(t1.row, t1.col+1).value == passW:
			print("Login successful")
			break
		else:
			print("Incorrect password")

choice = int(input("1) Sign Up\n2) Login\n>"))
if choice == 1:
	createAuth()
else:
	login()
Fetching token
?