Browse our guides and interact with our API reference for more information about MEDSAPI DynaMed/DynaMedex. Try MEDSAPI DynaMed/DynaMedex and learn about core concepts.

 

 

 

 

Get Trusted App Token Code Samples

Use the code samples below as examples to create an application in your desired language. The following code samples use the /user/trusted-app-token endpoint which allows you to get a JWT token to use in authentication. Get started and begin to understand the endpoint by following the examples below in the language of your choice.

 

Code Samples

cURL
# Builds a token for any outside consumer
curl -X GET "https://apis.ebsco.com/medsapi-dynamed/v1/user/trusted-app-token/{tokenConsumer}?expirationInSeconds=100&affiliation=admin.main"
    -H "Authorization: Bearer TOKEN"
    -H "Content-Type: application/json"
    -H "Accept: application/json"

Java
// Builds a token for any outside consumer

// Construct the client
OkHttpClient client = new OkHttpClient();

// Create the URL
HttpUrl url = new HttpUrl.Builder()
    .scheme("https")
    .host("apis.ebsco.com")
    .addPathSegment("medsapi-dynamed")
    .addPathSegment("v1")
    .addPathSegment("user")
    .addPathSegment("trusted-app-token")
    .addPathSegment("{tokenConsumer}")
    .addQueryParameter("expirationInSeconds", "100")
    .addQueryParameter("affiliation", "admin.main")
    .build();


// Build the request
Request request = new Request.Builder()
    .url(url)
    .get()
    .addHeader("Authorization, "Bearer TOKEN")
    .addHeader("Content-Type, "application/json")
    .addHeader("Accept, "application/json")
    .build();

// Send the request
Response response = client.newCall(request).execute();

JavaScript
// Builds a token for any outside consumer

const host = "https://apis.ebsco.com";
const path = "/medsapi-dynamed/v1/user/trusted-app-token/{tokenConsumer}";

// Create the Request
const url = host + path;
const queryParams = {"expirationInSeconds": "100", "affiliation": "admin.main"}

const settings = {
    "async": true,
    "crossDomain": true,
    "url": url,
    "method": "GET",
    "headers": {
        "Authorization": "Bearer TOKEN",
        "Content-Type": "application/json",
        "Accept": "application/json"
    },
    "data": queryParams
};

// Send the Request
$.ajax(settings).done(function (response) {
    console.log(response);
});

Ruby
# Builds a token for any outside consumer

# Form the URL
urlstr = File.join("https://", "apis.ebsco.com", "/medsapi-dynamed/v1/user/trusted-app-token/{tokenConsumer}")
url = URI.parse(urlstr)
params = { :expirationInSeconds => "100",:affiliation => "admin.main" }

# Add params to URI
uri.query = URI.encode_www_form( params )

# Create the HTTP object
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

# Create the request
request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer TOKEN"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"


# Send the request
response = http.request(request)

Python
# Builds a token for any outside consumer

# Form the URL
url = "/medsapi-dynamed/v1/user/trusted-app-token/{tokenConsumer}"

queryParams = {
    "expirationInSeconds": "100"
    "affiliation": "admin.main"}

# Create Connection Instance
conn = http.client.HTTPSConnection("apis.ebsco.com")

# Create the Request Headers
headers = {
        "Authorization": "Bearer TOKEN",
        "Content-Type": "application/json",
        "Accept": "application/json"
}

# Send Request
conn.request("GET", url, queryParams, headers)