Authorization and access

Thursday, 10 of June 2021

Introduction

The purpose of this section is to show how to perform auth and access actions in order to access RepCamp Api resources.


Generate a developer key

In order to call an API resource, is necessary to obtain an API KEY and a secret KEY associated to a contract. To obtain the keys, you have to access RepCamp with your user and password and access the manage subscrition area. At the bottom of the page you will find the key generation form. 

https://api.repcamp.com/apikey/generate

Sample Api Key/Secret Key generated

API KEY
cc0aa9e38fcc529fff5393078ab4a8cb
SECRET KEY
b6ec1f77f73f0cb3937a3833aa948d9226e23532a0b5aaafd5b113c01142ad5c
 

RepCamp request lifecycle

Every access has two steps. First step: obtain an access token (accesstoken). The acces token lasts 60 seconds and It will have to be regenerated in every call. Second step: call a resource using an api-token, key obtained as a result of the HMAC encription of the accesstoken retrieved and  the secret-key.
 

STEP 1. GET authtoken

https://api.repcamp.com/authtoken

Headers

Parameter Required? Description
api-key Yes API KEY linked to a repcamp contract
cc0aa9e38fcc529fff5393078ab4a8cb
Authorization Yes Basic auth
User/password of a repcamp user with the necessary rights to access the resources of a specific contract linked to an API KEY

 

Example Response

{
    "accesstoken": "5357a2acd5a0399c36000001",
    "expires": "60s"
}


 

 

STEP 2. Call a resource

http://api.repcamp.com/v1/customers

Headers

Parameter Required? Description
api-token Yes API TOKEN. HMAC encryption of the token retrieved in the first step using the secret key and SHA-1
accesstoken: 5357a2acd5a0399c36000001
secret key: b6ec1f77f73f0cb3937a3833aa948d9226e23532a0b5aaafd5b113c01142ad5c
api-token: 2a99713e60c3e040439a0b31bc97fa34e660abc1

 

Example response



[
{
"__v": 1,
"_id": "54b8f7d6bffd08381f0001a0",
"address": "27-29 King's Hill",
"city": "Westport",
"code": "0008",
"comercial_name": "Ár Frames",
"contract": "cae91e45aed80f3a3fe285c3c8c1a7e78d82d473",
"country": "IRLANDA",
"created_at": "2015-01-16T11:36:54.913Z",
"discount": 0,
"email": "orders@arframes.com",
"fiscal_name": "West Frames Ltd.",
"latitude": 0,
"longitude": 0,
"payment_method": "Bank Transfer 30 days",
"state": "Co. Mayo",
"telephone": "+353 98 55132",
"updated_at": "2015-01-16T20:00:38.805Z",
"vat_number": "D34591276",
"zip": "M004841",
"reps": [
{
"user": "54760688beb6f42c15000078",
"_id": "54b8f7d6bffd08381f0001a1",
"assigned_at": "2015-01-15T20:37:00.821Z"
},
{
"user": "54760688beb6f42c15000078",
"_id": "54b96de6bffd08381f0001e6",
"assigned_at": "2015-01-15T20:37:00.821Z"
}
],
"language": "en",
"status": 1
},
{
"__v": 1,
"_id": "54b8f7d6bffd08381f0001a6",
"address": "Av. Onze de Setembre, 150",
"city": "Cabrera de Mar",
"code": "0005",
"comercial_name": "La Siesta Company",
"contract": "cae91e45aed80f3a3fe285c3c8c1a7e78d82d473",
"country": "ESPAÑA",
"created_at": "2015-01-16T11:36:54.929Z",
"discount": 0,
"email": "marcos@siestaco.com",
"fiscal_name": "Siesta hermanos S.L.",
"latitude": 41.5280545,
"longitude": 2.3929959,
"payment_method": "Recibo 30 dias",
"state": "BARCELONA",
"telephone": "937840551",
"updated_at": "2015-01-16T20:00:38.821Z",
"vat_number": "N29347198",
"zip": "08349",
"reps": [
{
"user": "54760688beb6f42c15000078",
"_id": "54b8f7d6bffd08381f0001a7",
"assigned_at": "2015-01-15T20:37:00.821Z"
},
{
"user": "54760688beb6f42c15000078",
"_id": "54b96de6bffd08381f0001e9",
"assigned_at": "2015-01-15T20:37:00.821Z"
}
],
"language": "es",
"status": 1
}]