Skip to main content

SuccessFactors Auth

Authenticate with the SAP SuccessFactors API with OAuth2 and Python.

Dependencies

  • xmlsec
  • requests

System Requirements

  • libxml2 >= 2.9.1
  • libxmlsec1 >= 1.2.18

How to use

  1. Create an OAuth application in SuccessFactors.
  2. Download the private key and copy the Client ID.
  3. Install the Python module:
    pip install successfactors_auth
    
    Depending on your OS, you may need to install additional system packages, see xmlsec documentation.
    Note for macOS users: There is a bug that prevents you from installing xmlsec with Homebrew, currently tracked in a Github issue. There are some workaround you can try, but in the mean time it may be easier to install within a container or VM.
  4. Import successfactors_auth into your Python >=3.9 project.
  5. Call the successfactors_auth.get_token() function in your Python project. You'll need to pass the following parameters:
    • sf_url: Base API url of your SuccessFactors instance, e.g. "https://api55.sapsf.eu".
    • sf_company_id: SuccessFactors company ID.
    • sf_oauth_client_id: The Client ID for the OAuth application you created earlier.
    • sf_admin_user: An admin user in SuccessFactors that has access to the OAuth application.
    • sf_saml_private_key: Path to the private key file you downloaded when you created the OAuth application.

Example

#!/usr/bin/env python

import requests
import successfactors_auth as sf

sf_url = 'https://your.base.url.com'
sf_company_id = 'your-company-id'
sf_oauth_client_id = 'your_app_client_id'
sf_admin_user = 'your_admin_user'
sf_saml_private_key = 'app_private_key_file.pem'

token = sf.get_token(
    sf_company_id=company_id,
    sf_oauth_client_id=oauth_client_id,
    sf_admin_user=admin_api_user,
    sf_saml_private_key=oauth_private_key,
    sf_url=url
)

headers = {
    "Accept: application/json",
    f"Authorization: {token}"
}

request = requests.get(f"{sf_url}/User", headers=headers)
user = request.json()

print(user)

Background

I wrote this module because I was forced to deal with the horrific SAP SuccessFactors API at my job, and I wanted to make sure other devs/sysadmins wouldn't have to feel the pain that I felt.

Once you get authenticated, getting the information you want is a whole new level of suffering. I hope to publish some more examples in the form of a blog post or docs in this repo.

Contributing

All contributions welcome! Feel free to file an issue or open a pull request.

Metadata

Release files for successfactors-auth 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for successfactors-auth 0.0.10
File Size Uploaded
successfactors_auth-0.0.10.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for successfactors-auth 0.0.10
File Interpreter ABI Platform
successfactors_auth-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 19.3 kB

Release files / successfactors_auth-0.0.10.tar.gz

Download URL successfactors_auth-0.0.10.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2f9ddde83b08916c1ff4fb624e9e0f81e25c267841c9dfe353f448e9d76bfdba
BLAKE2b-256 checksum
How to use checksums
b713cf573af7077304b118ea7dfadaf1ee8b8091ff969a87432d0139edce79f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / successfactors_auth-0.0.10-py3-none-any.whl

Download URL successfactors_auth-0.0.10-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
135ac92c9c7ab65e2062e91fdf8ad2f81d9530e393f085d8ff312300dee1b47c
BLAKE2b-256 checksum
How to use checksums
0b3e2935860490c9618648139fa9a26292736b31db5f4c8af7a1fae16e9e1d84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

1 release file

0.0.5

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page