Function attribute within a class

0

I'm trying to use the Gmail API, and for now I'm on the right track, now I'm trying to make the execution of the program a little more orderly by adding conditional etc ... It turns out that I have the following problem:

I have a class called UsoApi and within this I have two methods called login and content_ver

The problem is that in the login method there is an attribute called service, which I need to use in the content_ver method, I have not been able to solve this problem, I am new to python3 thanks

class UsoApi:
def login(self):
    SCOPES = 'https://www.googleapis.com/auth/gmail.readonly'
    store = file.Storage('credentials.json')
    creds = store.get() 
    if not creds or creds.invalid:
        flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
        creds = tools.run_flow(flow, store)                 
        service = build('gmail', 'v1', http=creds.authorize(Http()))                            
    else:
        pass
        return True 

def contenido_ver(self):
    service = build('gmail', 'v1', http=creds.authorize(Http()))        
    userdatos = self.service.users().getProfile(userId='me').execute()
    email = userdatos.get('emailAddress',[])
    print(email)

I hope you can help me, thanks

    
asked by Diego Monsalve 04.06.2018 в 21:25
source

0 answers