File size: 516 Bytes
3985b9d
 
 
fed8298
4cf5ddf
 
 
3985b9d
4cf5ddf
3985b9d
 
 
 
 
 
 
4cf5ddf
3985b9d
fed8298
4cf5ddf
fed8298
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
import json
from google.oauth2.service_account import Credentials
import gspread

def connect_sheet():

    creds_dict = json.loads(os.environ["GOOGLE_CREDENTIALS"])

    credentials = Credentials.from_service_account_info(
        creds_dict,
        scopes=[
            "https://www.googleapis.com/auth/spreadsheets",
            "https://www.googleapis.com/auth/drive"
        ]
    )

    client = gspread.authorize(credentials)
    sheet = client.open_by_key("YOUR_SHEET_ID").sheet1

    return sheet