france-connect-py


Namefrance-connect-py JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttps://github.com/Codoc-os/france-connect-py
SummaryA Python client to handle communication with FranceConnect
upload_time2024-10-07 00:00:46
maintainerNone
docs_urlNone
authorCodoc
requires_pythonNone
licenseMIT License
keywords france-connect france-connect-py
VCS
bugtrack_url
requirements pyjwt requests
Travis-CI No Travis.
coveralls test coverage No coveralls.
            France Connect Py
=====================

[![PyPI Version](https://badge.fury.io/py/france-connect-py.svg)](https://badge.fury.io/py/france-connect-py)
![Tests](https://github.com/Codoc-os/france-connect-py/workflows/Tests/badge.svg)
[![Python 3.9+](https://img.shields.io/badge/Python-3.9+-brightgreen.svg)](#)
[![License MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/Codoc-os/france-connect-py/blob/main/LICENSE)
[![codecov](https://codecov.io/gh/Codoc-os/france-connect-py/branch/main/graph/badge.svg)](https://codecov.io/gh/Codoc-os/france-connect-py)
[![CodeFactor](https://www.codefactor.io/repository/github/Codoc-os/france-connect-py/badge)](https://www.codefactor.io/repository/github/Codoc-os/france-connect-py)

`france-connect-py` is a package allowing to interact with FranceConnect V2
through a single and easy-to-use class.

## Requirements

`france-connect-py` only support the supported version of each dependency (mainstream & lts).

* `Python` ([supported versions](https://devguide.python.org/versions/))

## Installation 

The easiest way to install `france-connect-py` is through `pip`:

* `pip install france-connect-py`

## How to use

You only need to import the `FranceConnect` class and create an instance to
start using the France Connect API.

```python
from france_connect.clients import FranceConnect
from france_connect.scopes import ACRValues, Scopes

fc = FranceConnect(
    client_id="<client_id>",
    client_secret="<client_secret>",
    scopes=[Scopes.PROFILE, Scopes.IDENTITE_PIVOT],
    login_callback_url="<login_callback_url>",
    logout_callback_url="<logout_callback_url>",
    fc_base_url="https://fcp-low.integ01.dev-franceconnect.fr",
)

# You can retrieve the FranceConnect's OpenID configuration as follow.
fc.get_configuration()

# Get the authorization URL.
#
# You can provide a specific `nonce` and `state` if needed, or let the class
# generate them as a random 64 bytes hex string. You can also inherit
# `FranceConnect` and override `generate_nonce()` and `generate_state()` to change
# the way they are generated.
# 
# `eidas1` is used as the default level of end user assurance, you can provide
# a different value using the `acr_values` parameter.
# For more information, see:
#   https://docs.partenaires.franceconnect.gouv.fr/fs/fs-technique/fs-technique-eidas-acr/
# 
# The `login_callback_url` provided at instantiation will be used as the
# callback URL, you can override it using the `callback_url` parameter.
url, nonce, state = fc.get_authorization_url(acr_values=[ACRValues.EIDAS2])


# The following code must be called when the user is redirected back to the
# service provider after a successful authentication of FranceConnect.
#
# Retrieve the code from the FranceConnect request
code = ...
# Retrieve the ID Token (the signature is verified automatically)
raw_token, decoded_token = fc.get_id_token(code)
# Retrieve the user's information using the ID Token (the signature is also
# verified automatically) `user_info` is a dictionary containing the user's
# information asked in the scopes.
user_info = fc.get_user_info(decoded_token["id_token"])


# To retrieve the logout url, uses `get_logout_url()`.
#
# The `logout_callback_url` provided at instantiation will be used as the
# callback URL, you can override it using the `callback_url` parameter.
logout_url = fc.get_logout_url(decoded_token["id_token"], state)
```

## Other

`france-connect-py` uses the `requests` library to interact with the France
Connect API. You can override how the library is used using the following
`FranceConnect` class parameters:

* `timeout: int = 10`
* `verify_ssl: bool = True`
* `allow_redirects: bool = True`

# Changelog

# 2.0.0 (2024-10-07)

* Initial release

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Codoc-os/france-connect-py",
    "name": "france-connect-py",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "france-connect france-connect-py",
    "author": "Codoc",
    "author_email": "support@codoc.co",
    "download_url": "https://files.pythonhosted.org/packages/f0/42/4b769c3fd49a87b5aadda6144fcf381cc2256d4b5368a3a8f07c1bf5b81c/france_connect_py-2.0.0.tar.gz",
    "platform": null,
    "description": "France Connect Py\n=====================\n\n[![PyPI Version](https://badge.fury.io/py/france-connect-py.svg)](https://badge.fury.io/py/france-connect-py)\n![Tests](https://github.com/Codoc-os/france-connect-py/workflows/Tests/badge.svg)\n[![Python 3.9+](https://img.shields.io/badge/Python-3.9+-brightgreen.svg)](#)\n[![License MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/Codoc-os/france-connect-py/blob/main/LICENSE)\n[![codecov](https://codecov.io/gh/Codoc-os/france-connect-py/branch/main/graph/badge.svg)](https://codecov.io/gh/Codoc-os/france-connect-py)\n[![CodeFactor](https://www.codefactor.io/repository/github/Codoc-os/france-connect-py/badge)](https://www.codefactor.io/repository/github/Codoc-os/france-connect-py)\n\n`france-connect-py` is a package allowing to interact with FranceConnect V2\nthrough a single and easy-to-use class.\n\n## Requirements\n\n`france-connect-py` only support the supported version of each dependency (mainstream & lts).\n\n* `Python` ([supported versions](https://devguide.python.org/versions/))\n\n## Installation \n\nThe easiest way to install `france-connect-py` is through `pip`:\n\n* `pip install france-connect-py`\n\n## How to use\n\nYou only need to import the `FranceConnect` class and create an instance to\nstart using the France Connect API.\n\n```python\nfrom france_connect.clients import FranceConnect\nfrom france_connect.scopes import ACRValues, Scopes\n\nfc = FranceConnect(\n    client_id=\"<client_id>\",\n    client_secret=\"<client_secret>\",\n    scopes=[Scopes.PROFILE, Scopes.IDENTITE_PIVOT],\n    login_callback_url=\"<login_callback_url>\",\n    logout_callback_url=\"<logout_callback_url>\",\n    fc_base_url=\"https://fcp-low.integ01.dev-franceconnect.fr\",\n)\n\n# You can retrieve the FranceConnect's OpenID configuration as follow.\nfc.get_configuration()\n\n# Get the authorization URL.\n#\n# You can provide a specific `nonce` and `state` if needed, or let the class\n# generate them as a random 64 bytes hex string. You can also inherit\n# `FranceConnect` and override `generate_nonce()` and `generate_state()` to change\n# the way they are generated.\n# \n# `eidas1` is used as the default level of end user assurance, you can provide\n# a different value using the `acr_values` parameter.\n# For more information, see:\n#   https://docs.partenaires.franceconnect.gouv.fr/fs/fs-technique/fs-technique-eidas-acr/\n# \n# The `login_callback_url` provided at instantiation will be used as the\n# callback URL, you can override it using the `callback_url` parameter.\nurl, nonce, state = fc.get_authorization_url(acr_values=[ACRValues.EIDAS2])\n\n\n# The following code must be called when the user is redirected back to the\n# service provider after a successful authentication of FranceConnect.\n#\n# Retrieve the code from the FranceConnect request\ncode = ...\n# Retrieve the ID Token (the signature is verified automatically)\nraw_token, decoded_token = fc.get_id_token(code)\n# Retrieve the user's information using the ID Token (the signature is also\n# verified automatically) `user_info` is a dictionary containing the user's\n# information asked in the scopes.\nuser_info = fc.get_user_info(decoded_token[\"id_token\"])\n\n\n# To retrieve the logout url, uses `get_logout_url()`.\n#\n# The `logout_callback_url` provided at instantiation will be used as the\n# callback URL, you can override it using the `callback_url` parameter.\nlogout_url = fc.get_logout_url(decoded_token[\"id_token\"], state)\n```\n\n## Other\n\n`france-connect-py` uses the `requests` library to interact with the France\nConnect API. You can override how the library is used using the following\n`FranceConnect` class parameters:\n\n* `timeout: int = 10`\n* `verify_ssl: bool = True`\n* `allow_redirects: bool = True`\n\n# Changelog\n\n# 2.0.0 (2024-10-07)\n\n* Initial release\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "A Python client to handle communication with FranceConnect",
    "version": "2.0.0",
    "project_urls": {
        "Homepage": "https://github.com/Codoc-os/france-connect-py"
    },
    "split_keywords": [
        "france-connect",
        "france-connect-py"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f0424b769c3fd49a87b5aadda6144fcf381cc2256d4b5368a3a8f07c1bf5b81c",
                "md5": "d924e7455b97c7b296866e8ef083943d",
                "sha256": "e5480a2ff4dedbbff1fce8f046b1d88d7cb5cd5a81a4f0a2c20b65d2154632e8"
            },
            "downloads": -1,
            "filename": "france_connect_py-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d924e7455b97c7b296866e8ef083943d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9841,
            "upload_time": "2024-10-07T00:00:46",
            "upload_time_iso_8601": "2024-10-07T00:00:46.336251Z",
            "url": "https://files.pythonhosted.org/packages/f0/42/4b769c3fd49a87b5aadda6144fcf381cc2256d4b5368a3a8f07c1bf5b81c/france_connect_py-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-07 00:00:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Codoc-os",
    "github_project": "france-connect-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pyjwt",
            "specs": [
                [
                    "<",
                    "3.0.0"
                ],
                [
                    ">=",
                    "2.9.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "<",
                    "3.0.0"
                ],
                [
                    ">=",
                    "2.32.3"
                ]
            ]
        }
    ],
    "lcname": "france-connect-py"
}
        
Elapsed time: 1.58674s