OEG Best Practice: Anaplan Python OAuth Example

The Anaplan Python OAuth Example demonstrates using the Anaplan REST API with OAuth with device-based authorization. The code highlights how to generate a device_idaccess_token, and refresh_token. Additionally, the code highlights a multi-threaded approach to request a new access_token while performing other, longer-running operations such as a large data load. Please note that with this code example, the concept is simulated by calling Get Workspaces five times every 10 seconds while simultaneously refreshing the access_token every 5 seconds. Please note that the access_token expires after 35 minutes, so please adjust the timer to a value just below this expiration length (2100 seconds). Usage and the source code can be viewed here.

Here is a brief overview of the example:

1) New device-based Oauth Registration:

2) After a successful registration, run unattended mode:

3) To see all command line arguments, type: 'python3 anaplan.py -h'

4) To update any of the Anaplan API URLs, please edit the file settings.json.

Note: The client_id and refresh_token are stored as encrypted values in a SQLite database. As an alternative, a solution like auth0 would further enhance security.

Author: Quin Eddy, @QuinE - Director of Data Integration, Operational Excellence Group (OEG)

Comments

  • The Anaplan Python OAuth Example demonstrates using the Anaplan REST API with OAuth with device-based authorization.

  • Please note that the code base has been updated to support rotatable and non-rotatable tokens. The code has also been cleaned up and aligned to the style used in the Anaplan Enhanced Audit Solution.

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In