Skip to main content

pegass_auth is a tiny client tool to help you make some HTTP request on Pegass

Project description


Made Pegass API Request easy !


French Red Cross is currently using a tool named Pegass to visualize, enroll to activities, monitor them and more... This application is carefully thought out, and the different views give you plenty options to display your data. However, my motivation was to extract Pegass data to analyze it and create some custom views. The application was not designed to let users get data out of the box (closed API, no CSV extract, ...). That's why I made this little module to help whoever wants to extract their data in a simple way through the Pegass API. :red_car: :red_car: :fire_engine: :fire_engine: :rotating_light: :rotating_light:


  • Get authentication cookies to open Pegass API gate with your application credential
  • Create an abstraction for requesting the API


# Connect to your virtualenv
$  workon projectenv

# Use pip to install the package
$  pip install pegass_auth

Verify now if the package as been successfully installed

$  python
>> import pegass_auth # Should not raise exception

Quick Start

Get authentication cookies to make requests out of the box

import os
import requests
import pegass_auth

username = os.environ['username']
password = os.environ['password']

auth_cookies = pegass_auth.login(username, password)

# When using 'requests' package
r = requests.get('{}/crf/rest/gestiondesdroits'.format(pegass_auth.DEFAULT_PEGASS_URL), cookies=auth_cookies)

if r.status_code == 200:
    print('Request went wrong ! Status code returned : {}'.format(r.status_code))

Using package abstraction to make request

The package gives you two ways to make a request to Pegass API :

  • Using cookies :
import os
import pegass_auth as pegass

auth_cookies = login(os.environ['username'], os.environ['password'])
rules = pegass.request('crf/rest/gestiondesdroits', cookies=auth_cookies)
  • Using credentials:
import os
import pegass_auth as pegass

username = os.environ['username']
password = os.environ['password']
rules = pegass.request('crf/rest/gestiondesdroits', username=username, password=password)

Note: The last way to make request (the one with username and password) runs each time the login logic. Make cookies methods your first choice if you need to do multiple API requests.

All the previous codes prints the following response:

         'libelle':'UNITE LOCALE DE XXXXXXX',
         'telephone':'X XX XX XX XX',
               'libelle':'UNITE LOCALE DE XXXXXXX'


Pegass API Endpoints

I've started to do a reverse engineering on Pegass app to list the API endpoints I need in order to achieve my personal app.

Error handler

Their is no error handler implemented yet in the package.



Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pegass_auth-1.0.2.tar.gz (4.2 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page