How do I authorize a gdata client without using the gdata oauth2 workflow?

后端 未结 3 870
抹茶落季
抹茶落季 2021-01-03 09:26

I already have an access_token and refresh_token, but I can\'t figure out a way to create an authorized gdata client without going through the entire token generation workfl

3条回答
  •  渐次进展
    2021-01-03 09:48

    So I got this working finally. Here's how I did it:

        client = gdata.contacts.client.ContactsClient()
        credentials = gdata.gauth.OAuth2Token(client_id = 'client_id',
                                              client_secret = 'client_secret',
                                              scope = 'https://www.google.com/m8/feeds/',
                                              user_agent = auth.user_agent, # This is from the headers sent to google when getting your access token (they don't return it)
                                              access_token = auth.access_token,
                                              refresh_token = auth.refresh_token)
    
        credentials.authorize(client)
        contacts = client.get_contacts()
    

提交回复
热议问题