GetPartnerAccessTokens
The GetPartnerAccessTokens gives access to all the partner tokens that give you access to invoicing on behalf of them. A partner can be allocated with more than one token. This allows a partner to be identified in more than one identifier, if needed.
This is the only method that requires the password of the main API user of IPPN service. Passwords must be securely stored, ideally on a separate system from the system used for the rest of the operations.
GET https://bo.magnifinance.com/api/v1.1/partner/accessTokens?partnerTaxId={partnerTaxId}
Request
Header
| Parameter | Required | Value |
|---|---|---|
| required | string(50) The email address of the owner of the IPPN service with specific permissions to use IPPN services. Example: api@example.com | |
| Token | required | The token for the IPPN account is specific to your IPPN service and is provided by our commercial team. |
| Password | required | The password of the user that was set up to be the main user of your IPPN service. |
*These parameters must be HTTP headers within the request.
Query
| Parameter | Required | Description |
|---|---|---|
| partnerTaxId | required | int Tax id of the partner organization whose tokens will be retrieved. Example value: "599138645". In the REST API you should request as a query string parameter in the URL. Example: ?partnerTaxId=599138645 |
Response
| Parameter | Description |
|---|---|
| RequestId | Unique Id for the request to have a way to identify the request |
| Object | List of APIAccessTokenBase |
| - AccessToken | string Security token that provides access to the requested partner organization's subscription. |
| - Description | string Description that can be used to differentiate between tokens. |
| Type | string Description to inform if the request was a success or error. Example value: "Success" |
| ErrorValue | MagniEnum |
| - Value | int Identifies the error with a number. To identify the types of errors in more detail, click here. Example value: "38" |
| - Name | string Identifies the error with a token. Example value: "PartnershipNotFound" |
| ErrorHumanReadable | string Text that explains the error found. Example value: "ValidationError" |
| ValidationErrors | List of ValidationError |
| - Type | string Identifies the error with a token. Example value: "DocumentIsADuplicate" |
| - Field | string Name of the field in which validation failed. Example value: "DocumentDetailExternalId" |
| - ElementNumber | int Identifies index of the field in which validation failed. Example value: "67204" |
| - Detail | string Detailed error explanation. Example value: "Duplicate Document" |
| IsSuccess | boolean Whether the request succeeded or not. Example value: "true" |
| IsError | boolean Whether the request failed or not. Example value: "false" |
Request Sample
Below you can check some examples of the REST request in some technologies.
cURL
curl --location 'https://bo.magnifinance.com/api/v1.1/partner/accessTokens?partnerTaxId=XXX' \
--header 'Email: XXX@example.com' \
--header 'Token: XXX' \
--header 'password: XXX'
Javascript (fetch)
var myHeaders = new Headers();
myHeaders.append("Email", "XXX@example.com");
myHeaders.append("Token", "XXX");
myHeaders.append("password", "XXX");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://bo.magnifinance.com/api/v1.1/partner/accessTokens?partnerTaxId=XXX", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
NodeJs (axios)
var axios = require('axios');
var config = {
method: 'get',
maxBodyLength: Infinity,
url: 'https://bo.magnifinance.com/api/v1.1/partner/accessTokens?partnerTaxId=XXX',
headers: {
'Email': 'XXX@example.com',
'Token': 'XXX',
'password': 'XXX'
}
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python (requests)
import requests
url = "https://bo.magnifinance.com/api/v1.1/partner/accessTokens"
headers = {
"Email": "XXX@example.com",
"Token": "XXX",
"password": "XXX"
}
params = {"partnerTaxId": "XXX"}
response = requests.get(url, headers=headers, params=params)
print(response.json())
PHP (cURL)
<?php
$partnerTaxId = "XXX";
$ch = curl_init("https://bo.magnifinance.com/api/v1.1/partner/accessTokens?partnerTaxId=" . $partnerTaxId);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Email: XXX@example.com",
"Token: XXX",
"password: XXX"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
C# (HttpClient)
using System.Net.Http;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Email", "XXX@example.com");
client.DefaultRequestHeaders.Add("Token", "XXX");
client.DefaultRequestHeaders.Add("password", "XXX");
var response = await client.GetAsync("https://bo.magnifinance.com/api/v1.1/partner/accessTokens?partnerTaxId=XXX");
Console.WriteLine(await response.Content.ReadAsStringAsync());
Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://bo.magnifinance.com/api/v1.1/partner/accessTokens?partnerTaxId=XXX"))
.header("Email", "XXX@example.com")
.header("Token", "XXX")
.header("password", "XXX")
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Important Information
With the token in hand, you can use it, call the DocumentCreate method, replacing the token in the authentication/header with the partnerToken (so you can create a document on behalf of the partner).