Skip to content

Commit

Permalink
Use only one token, renamed environment variables (#40)
Browse files Browse the repository at this point in the history
* only one token from now on

* renamed variables
  • Loading branch information
golnazads authored and marblestation committed Aug 3, 2018
1 parent 4ca3e14 commit 57720b1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

# These are the URL and token for resolver_service api
RESOLVER_SERVICE_URL = 'https://dev.adsabs.harvard.edu/v1/resolver/%s'
RESOLVER_SERVICE_ADSWS_API_TOKEN = 'this is a secret api token!'
# This the URL to resolver_service api
GATEWAY_RESOLVER_SERVICE_URL = 'https://dev.adsabs.harvard.edu/v1/resolver/%s'

# Service URL to translate session into user account information
RESOLVER_SERVICE_ACCOUNT_TOKEN_URL = 'https://qa.adsabs.harvard.edu/v1/accounts/info'
RESOLVER_SERVICE_ADSWS_API_INFO_TOKEN = 'this is a secret api token!'
# This is a URL to adsws account info service
GATEWAY_SERVICE_ACCOUNT_INFO_URL = 'https://qa.adsabs.harvard.edu/v1/accounts/info'

# gateway token
GATEWAY_TOKEN = 'this is a secret api token!'

# For caching
REDIS_URL = "redis://localhost:6379/0"
5 changes: 3 additions & 2 deletions local_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
LOG_LEVEL = 30 # To be deprecated when all microservices use ADSFlask
LOGGING_LEVEL = "INFO"
DISCOVERER_SELF_PUBLISH = True
RESOLVER_SERVICE_ACCOUNT_TOKEN_URL = ""
RESOLVER_SERVICE_ADSWS_API_INFO_TOKEN = ""
GATEWAY_RESOLVER_SERVICE_URL = "https://qa.adsabs.harvard.edu/v1/resolver/%s"
GATEWAY_SERVICE_ACCOUNT_INFO_URL = ""
GATEWAY_TOKEN = ""
REDIS_URL = ""


Expand Down
8 changes: 4 additions & 4 deletions resolverway/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def get_user_info_from_adsws(self, session):
if session:
try:
current_app.logger.info('getting user info from adsws for %s' % (session))
url = current_app.config['RESOLVER_SERVICE_ACCOUNT_TOKEN_URL'] + '/' + session
headers = {'Authorization': 'Bearer ' + current_app.config['RESOLVER_SERVICE_ADSWS_API_INFO_TOKEN']}
url = current_app.config['GATEWAY_SERVICE_ACCOUNT_INFO_URL'] + '/' + session
headers = {'Authorization': 'Bearer ' + current_app.config['GATEWAY_TOKEN']}
r = requests.get(url=url, headers=headers)
if r.status_code == 200:
current_app.logger.info('got results=%s' % (r.json()))
Expand Down Expand Up @@ -151,8 +151,8 @@ def process_request(self):
params = self.bibcode + '/' + self.link_type + ':' + self.id
else:
params = self.bibcode + '/' + self.link_type
headers = {'Authorization': 'Bearer ' + current_app.config['RESOLVER_SERVICE_ADSWS_API_TOKEN']}
response = requests.get(url=current_app.config['RESOLVER_SERVICE_URL'] %(params), headers=headers)
headers = {'Authorization': 'Bearer ' + current_app.config['GATEWAY_TOKEN']}
response = requests.get(url=current_app.config['GATEWAY_RESOLVER_SERVICE_URL'] %(params), headers=headers)

contentType = response.headers.get('content-type')

Expand Down

0 comments on commit 57720b1

Please sign in to comment.