The EBSCOhost Entitlement API makes research easy by providing access to full text content from EBSCOhost full text databases.

 

 

 

 

Clone a Code Sample

After you explore our API reference and code samples, you can clone one of our code samples to get you started. Our documentation contains a code sample for each resource in four different languages. Whatever language that you are using, you can use our Python code sample below as a model and tweak the parameters to get your desired request.

First, you must create the code in your app to acquire an access token.  OAuth 2.0 describes a number of grants (methods) for a client application to acquire the access token needed.  It must be decided which OAuth 2.0 grant type you are going to use in order to receive the access token.  The grant type used depends on the use case.  The most common OAuth 2.0 grant types are listed below.

  • Authorization Code - Used for Apps running a web server, browser based and mobile apps.
  • Password - Used for loggin in with a username and password.
  • Client Credentials - Used for application access.
  • Implicit - Originally recommended for clients without a secret, but has been superceded by the Authorization Code grant type with no secret.

The authorization flow, or process, for obtaining the access token differs depending on the grant type.  Regardless of the grant type used, the result of the OAuth 2.0 authorization flow is an access token.  Please refer to the Use the Client Credentials Grant Type guide for more information.

After your client app is able to receive an access token, you are ready to create the code to use the API endpoints.  In the following code sample, we create a code sample for Entitlement API.  We execute a request to resolve a customer identity and DOI into a link using the staging environment.  The process of creating the code sample for the resource is described below.  For this particular example, we used windows and installed Python 3.6.0 prior to creating the sample.

Note: If you need to look up the URL or parameters for a resource, refer back to the API reference or code sample documentation.

To Create a Code Sample:

  1. Note the request URL for your desired resource.

Request URL


https://ebscois-staging.apigee.net/ehostentitlements/{profile}/discovery

  1. Determine the parameters that you would like to use for your request.

Parameters


profile = {EBSCO provided customer.group.profle}
doi = {doi query}
token = {token}
x-forwarded-host = {host of link resolver}
x-forwarded-proto = {protocol of link resolver}
Authorization = {Access token obtained from the OAuth2.0 process}

Please refer to our API Reference for more information on the parameters.

  1. Create a new sample.py file for your sample code.
  2. Add the following code to sample.py.  The code below defines your parameters, forms the request URL, forms the request headers, sends the request and gets the response back.

# File: sample.py
 
# HTTP Library
import http.client
 
# Parameters
CGP = {EBSCO provided customer.group.profile}
TOKEN = {token}
PROTO = {protocol of link resolver}
HOST = {host of link resolver}
DOI = {DOI}

# Form the URL
url = ''.join(['/ehostentitlements/', CGP, '/discovery'])
authorization_str = ''.join(['Bearer',' ', ACCESS_TOKEN])

# Create Connection Instance
conn = http.client.HTTPSConnection("ebscois-staging.apigee.net")
 
# Set the Query Parameters
params = urllib.parse.urlencode({'doi': DOI})

# Create the Request Headers
headers = {
    'accept': "application/json",
    'token': TOKEN,
    'x-forwarded-proto': PROTO,
    'x-forwarded-host': HOST,
    'Authorization': authorization_str
    }
 
# Send Request 
conn.request("GET", url + '?' + params, headers=headers)
 
# Get Response
res = conn.getresponse()
data = res.read()
 
 
print(data.decode("utf-8"))  

  1. Change {EBSCO provided customer.group.profile}, {token}, {protocol of link resolver), {host of link resolver} and {DOI} in the sample.py script to the paramers that you gathered in Step 2.
  2. Save your sample.py file.
  3. Run your script by entering python sample.py in a Command Prompt.  If successful, a JSON response with the link resolved will be returned and displayed on the screen.

{
  "link": "http://search.ebscohost.com/login.aspx?direct=true&scope=site&db=aph&AN=16133335&ErrorURL=http%3A%2F%2Flinksource%2Eebsco%2Ecom%2Ferror%2Easpx"
}

You have completed your first code sample consuming Entitlement API. You are on your way. Have fun!