Skip to content

Instantly share code, notes, and snippets.

@srusskih
Last active September 5, 2016 14:00
Show Gist options
  • Save srusskih/2466db0612adf12f6bb3c3671acf9611 to your computer and use it in GitHub Desktop.
Save srusskih/2466db0612adf12f6bb3c3671acf9611 to your computer and use it in GitHub Desktop.
import httplib2
from googleapiclient.http import HttpMock
class OAuth2Credentials:
def set_store(self, store):
pass
@classmethod
def from_json(cls, data):
return cls()
def authorize(self, http):
return httplib2.Http(disable_ssl_certificate_validation=True)
from googleapiclient import discovery
from oauth2client.file import Storage
store = Storage('testcreds.json')
creds = store.get()
# Now we can use WireMock to stub responses to Google API
mocked_dfa = discovery.build('dfareporting', 'v2.5', credentials=creds, cache_discovery=False)
response = mocked_dfa.reports().list(profileId=123456).execute()
{
"_module": "fake_oauthclient",
"_class": "OAuth2Credentials"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment