HomeGuidesAPI ReferenceGuidesMRT APIConfiguration API
GitHubAirheads Developer Community
Guides

Generating a Unified Token for GLP

📘

Source Code

You can find this playbook in the collection repository: examples/unified_token.yml

This playbook generates an OAuth token from unified credentials and uses it to call GLP. Unified credentials are useful when a workflow needs GLP only, or both GLP and New Central, from a single set of client credentials scoped to a GreenLake workspace.

Prerequisites

  • A GreenLake workspace with API access enabled
  • A client_id, client_secret, and workspace_id for the workspace

Installation

  1. Install the collection from Ansible Galaxy:
ansible-galaxy collection install arubanetworks.hpeanw_central
  1. Install the pycentral v2 SDK, which the collection depends on:
pip3 install --pre pycentral

This workflow is tested on collection version 2.1.1-beta. Please check compatibility before executing on older/newer versions as there may be changes.

Configuration

Credentials Configuration (inventory.yml)

all:
  hosts:
    localhost:
      ansible_connection: local # Do not change
      glp_client_id: <glp-client-id>
      glp_client_secret: <glp-client-secret>
      glp_workspace_id: <glp-workspace-id>
📘

Important Links

Execution

- name: Generate unified token and use with GLP API
  hosts: localhost
  gather_facts: no
  tasks:
    - name: Create unified OAuth Token for GLP only
      arubanetworks.hpeanw_central.unified_token:
        client_id: "{{ glp_client_id }}"
        client_secret: "{{ glp_client_secret }}"
        workspace_id: "{{ glp_workspace_id }}"
      register: token_result
      no_log: true

    - name: Get GLP devices with generated unified token
      arubanetworks.hpeanw_central.glp_devices_info:
        access_token: "{{ token_result['access_token'] }}"
      register: devices_result

    - debug:
        var: devices_result

Run it with:

ansible-playbook -i inventory.yml unified_token.yml

Module Parameters (unified_token)

ParameterTypeRequiredDescription
client_idstrYesClient ID for the GLP workspace
client_secretstrYesClient secret for the GLP workspace
workspace_idstrYesGreenLake workspace ID associated with the credentials

Output

token_result contains access_token — the generated OAuth token, usable with any GLP module in the same playbook run.

Troubleshooting

ProblemFix
401/403 on token generationVerify client_id/client_secret are valid and scoped to workspace_id
Workspace not foundConfirm workspace_id matches the GreenLake workspace the credentials belong to
Token works for GLP but not CentralUnified tokens generated this way are GLP-scoped; use central_token for New Central calls

Support


Did this page help you?