OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Python API for retrieving API keys. | 6 """Python API for retrieving API keys. |
7 | 7 |
8 Note that this does not have the exact same semantics as the C++ API | 8 Note that this does not have the exact same semantics as the C++ API |
9 in google_api_keys.h, since it does not have access to gyp variables | 9 in google_api_keys.h, since it does not have access to gyp variables |
10 or preprocessor defines. | 10 or preprocessor defines. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 return token | 63 return token |
64 else: | 64 else: |
65 return DUMMY_TOKEN | 65 return DUMMY_TOKEN |
66 | 66 |
67 | 67 |
68 def GetAPIKey(): | 68 def GetAPIKey(): |
69 """Returns the simple API key.""" | 69 """Returns the simple API key.""" |
70 return _GetToken('GOOGLE_API_KEY') | 70 return _GetToken('GOOGLE_API_KEY') |
71 | 71 |
72 | 72 |
| 73 def GetAPIKeyPhysicalWebTest(): |
| 74 """Returns the API key to test Physical Web service.""" |
| 75 return _GetToken('GOOGLE_API_KEY_PHYSICAL_WEB_TEST') |
| 76 |
| 77 |
73 def GetAPIKeyRemoting(): | 78 def GetAPIKeyRemoting(): |
74 """Returns the simple API key.""" | 79 """Returns the simple API key.""" |
75 return _GetToken('GOOGLE_API_KEY_REMOTING') | 80 return _GetToken('GOOGLE_API_KEY_REMOTING') |
76 | 81 |
77 | 82 |
78 def GetClientID(client_name): | 83 def GetClientID(client_name): |
79 """Returns the OAuth 2.0 client ID for the client of the given name.""" | 84 """Returns the OAuth 2.0 client ID for the client of the given name.""" |
80 return _GetToken('GOOGLE_CLIENT_ID_%s' % client_name) | 85 return _GetToken('GOOGLE_CLIENT_ID_%s' % client_name) |
81 | 86 |
82 | 87 |
83 def GetClientSecret(client_name): | 88 def GetClientSecret(client_name): |
84 """Returns the OAuth 2.0 client secret for the client of the given name.""" | 89 """Returns the OAuth 2.0 client secret for the client of the given name.""" |
85 return _GetToken('GOOGLE_CLIENT_SECRET_%s' % client_name) | 90 return _GetToken('GOOGLE_CLIENT_SECRET_%s' % client_name) |
86 | 91 |
87 | 92 |
88 if __name__ == "__main__": | 93 if __name__ == "__main__": |
89 print 'GOOGLE_API_KEY=%s' % GetAPIKey() | 94 print 'GOOGLE_API_KEY=%s' % GetAPIKey() |
90 print 'GOOGLE_API_KEY_REMOTING=%s' % GetAPIKeyRemoting() | 95 print 'GOOGLE_API_KEY_REMOTING=%s' % GetAPIKeyRemoting() |
91 print 'GOOGLE_CLIENT_ID_MAIN=%s' % GetClientID('MAIN') | 96 print 'GOOGLE_CLIENT_ID_MAIN=%s' % GetClientID('MAIN') |
92 print 'GOOGLE_CLIENT_SECRET_MAIN=%s' % GetClientSecret('MAIN') | 97 print 'GOOGLE_CLIENT_SECRET_MAIN=%s' % GetClientSecret('MAIN') |
93 print 'GOOGLE_CLIENT_ID_CLOUD_PRINT=%s' % GetClientID('CLOUD_PRINT') | 98 print 'GOOGLE_CLIENT_ID_CLOUD_PRINT=%s' % GetClientID('CLOUD_PRINT') |
94 print 'GOOGLE_CLIENT_SECRET_CLOUD_PRINT=%s' % GetClientSecret('CLOUD_PRINT') | 99 print 'GOOGLE_CLIENT_SECRET_CLOUD_PRINT=%s' % GetClientSecret('CLOUD_PRINT') |
95 print 'GOOGLE_CLIENT_ID_REMOTING=%s' % GetClientID('REMOTING') | 100 print 'GOOGLE_CLIENT_ID_REMOTING=%s' % GetClientID('REMOTING') |
96 print 'GOOGLE_CLIENT_SECRET_REMOTING=%s' % GetClientSecret('REMOTING') | 101 print 'GOOGLE_CLIENT_SECRET_REMOTING=%s' % GetClientSecret('REMOTING') |
97 print 'GOOGLE_CLIENT_ID_REMOTING_HOST=%s' % GetClientID('REMOTING_HOST') | 102 print 'GOOGLE_CLIENT_ID_REMOTING_HOST=%s' % GetClientID('REMOTING_HOST') |
98 print 'GOOGLE_CLIENT_SECRET_REMOTING_HOST=%s' % GetClientSecret( | 103 print 'GOOGLE_CLIENT_SECRET_REMOTING_HOST=%s' % GetClientSecret( |
99 'REMOTING_HOST') | 104 'REMOTING_HOST') |
100 print 'GOOGLE_CLIENT_ID_REMOTING_IDENTITY_API=%s' %GetClientID( | 105 print 'GOOGLE_CLIENT_ID_REMOTING_IDENTITY_API=%s' %GetClientID( |
101 'REMOTING_IDENTITY_API') | 106 'REMOTING_IDENTITY_API') |
OLD | NEW |