Last active
September 5, 2016 14:00
-
-
Save srusskih/2466db0612adf12f6bb3c3671acf9611 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_module": "fake_oauthclient", | |
"_class": "OAuth2Credentials" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment