Skip to content

Commit 12122b5

Browse files
committed
fixed the get_service() method and added discoveryServiceUrl
1 parent d6b5f24 commit 12122b5

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

language/api/analyze.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,17 @@
2929

3030
# TODO REMOVE - when discovery is public
3131
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')
4333

44-
# TODO REMOVE - when discovery is public
4534
def get_service():
46-
"""Get language service using discovery."""
47-
import os
48-
api_key = os.environ[GOOGLE_API_KEY]
4935
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+
5443

5544
def get_native_encoding_type():
5645
"""Returns the encoding type that matches Python's native strings."""

0 commit comments

Comments
 (0)