kruegge82/dhl-authentication-oauth-api

This API describes how API client can obtain a token which is used to access various Parcel Germany APIs. Using this API is often the first step in making your API call. <p><h3>Preconditions</h3> You will need: * client ID (aka "API Key", obtained when you create an app in developer.dhl.com) * clie

v2.0.7 2025-02-05 12:15 UTC

This package is auto-updated.

Last update: 2025-02-05 12:16:14 UTC


README

This API describes how API client can obtain a token which is used to access various Parcel Germany APIs. Using this API is often the first step in making your API call.

Preconditions

You will need:
  • client ID (aka "API Key", obtained when you create an app in developer.dhl.com)
  • client secret (obtained when you create an app in developer.dhl.com)
  • GKP user name (obtained when setting up your business account with Parcel Germany)
  • GKP password (obtained when setting up your business account with Parcel Germany)

Technical Information

This uses an implementation of OAuth2 Password Grant (RFC 6749). After successfull usage you will:
  • have an opaque access token to be used for API calls afterwards
  • this token will have an expiration time

Installation & Usage

Requirements

PHP 8.1 and later.

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
    }
  ],
  "require": {
    "GIT_USER_ID/GIT_REPO_ID": "*@dev"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

<?php
require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

$prod=false;

$config = Configuration::getDefaultConfiguration();
$config->setHost($config->getHostString($config->getHostSettings(), $prod)); //0=Sandbox 1=Productive

$apiInstance = new kruegge82\DHLAuth\Api\AuthenticationApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$grant_type = 'grant_type_example'; // string
$username = 'username_example'; // string | GKP user name. Required for grant_type=password.
$password = 'password_example'; // string | GKP password. Required for grant_type=password.
$client_id = 'client_id_example'; // string
$client_secret = 'client_secret_example'; // string

try {
    $result = $apiInstance->dispenseToken($grant_type, $username, $password, $client_id, $client_secret);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AuthenticationApi->dispenseToken: ', $e->getMessage(), PHP_EOL;
}

API Endpoints

All URIs are relative to https://api-sandbox.dhl.com/parcel/de/account/auth/ropc/v1

Models

Authorization

bearerAuth

  • Type: Bearer authentication (Apigee)

Tests

To run the tests, use:

composer install
vendor/bin/phpunit

Author

About this package

This PHP package is automatically generated by the OpenAPI Generator project:

  • API version: 2.0.5
    • Generator version: 7.12.0-SNAPSHOT
  • Build package: org.openapitools.codegen.languages.PhpNextgenClientCodegen