File size: 624 Bytes
9df0420
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import os
from google.oauth2 import service_account
from google.auth.transport.requests import Request

class Authenticator:
    def __init__(self, credentials_file):
        self.credentials_file = credentials_file

    def authenticate(self):
        # Load credentials from file
        credentials = service_account.Credentials.from_service_account_file(
            self.credentials_file, scopes=['https://www.googleapis.com/auth/cloud-platform']
        )
        # Create a client instance with the credentials
        client = Request()
        credentials.refresh_token = client.request()
        return credentials