|
29 | 29 |
|
30 | 30 | # TODO REMOVE - when discovery is public |
31 | 31 | DISCOVERY_URL = ('https://language.googleapis.com/$discovery/rest?' |
32 | | - 'version=v1&labels=GOOGLE_INTERNAL&key={}') |
33 | | - |
34 | | -# TODO UNCOMMENT - when discovery is public |
35 | | -# def get_service(): |
36 | | -# credentials = GoogleCredentials.get_application_default() |
37 | | -# scoped_credentials = credentials.create_scoped( |
38 | | -# ['https://www.googleapis.com/auth/cloud-platform']) |
39 | | -# http = httplib2.Http() |
40 | | -# scoped_credentials.authorize(http) |
41 | | -# return discovery.build('language', 'v1', http=http) |
42 | | -# TODO END |
| 32 | + 'version=v1&labels=GOOGLE_INTERNAL') |
43 | 33 |
|
44 | | -# TODO REMOVE - when discovery is public |
45 | 34 | def get_service(): |
46 | | - """Get language service using discovery.""" |
47 | | - import os |
48 | | - api_key = os.environ[GOOGLE_API_KEY] |
49 | 35 | credentials = GoogleCredentials.get_application_default() |
50 | | - service = discovery.build('language', 'v1', http=httplib2.Http(), credentials=credentials, |
51 | | - discoveryServiceUrl=DISCOVERY_URL.format(api_key)) |
52 | | - return service |
53 | | -# TODO END |
| 36 | + scoped_credentials = credentials.create_scoped( |
| 37 | + ['https://www.googleapis.com/auth/cloud-platform']) |
| 38 | + http = httplib2.Http() |
| 39 | + scoped_credentials.authorize(http) |
| 40 | + return discovery.build('language', 'v1', http=http, |
| 41 | + discoveryServiceUrl=DISCOVERY_URL) |
| 42 | + |
54 | 43 |
|
55 | 44 | def get_native_encoding_type(): |
56 | 45 | """Returns the encoding type that matches Python's native strings.""" |
|
0 commit comments