pymaskinporten
This is a python package to request a token from Maskinporten - the Norwegian national access control solution for businesses that exchange data.
graph LR
Consumer["Application"] -- request token ---> Maskinporten
Maskinporten -- issue new token ---> Consumer
Consumer -- use token ---> Service["External Service"]
Example usage
This assumes that:
- You have created the integration on digidir.no and,
- You have set the necessary environment variables for your API credentials.
# set environment variables for your API
import os
os.environ["KID"] = "your_kid"
os.environ["PRIVATE_KEY"] = "your_private_key"
os.environ["MASKINPORTEN_CLIENT_ID"] = "your_client_id"
os.environ["SCOPE"] = "your_scope"
# get the access token
from pymaskinporten.request_token import request_maskinporten_token
access_token, expires_in = request_maskinporten_token("test")
print(f"Access Token: {access_token}")
print(f"Expires In: {expires_in} seconds")
Docker container
If you want to test the library through a web browser the image opens a flask app:
cat > .env <<EOF
MASKINPORTEN_CLIENT_ID=your-client-id
KID=your-kid
SCOPE=your-scope
EOF
docker run -p 127.0.0.1:5000:5000 --env-file .env \
-e PRIVATE_KEY="$(cat private_key.pem)" \
ghcr.io/norwegianveterinaryinstitute/pymaskinporten:main
--env-file keeps quotes as part of the value and doesn't support multi-line values, so leave
the values unquoted and pass the PEM key with -e. In PowerShell, use
-e PRIVATE_KEY="$(Get-Content -Raw private_key.pem)".
Then open http://127.0.0.1:5000.
Metadata
Release files for pymaskinporten 1.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pymaskinporten-1.1.4.tar.gz | 6.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pymaskinporten-1.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.4 kB
Release files / pymaskinporten-1.1.4.tar.gz
| Download URL | pymaskinporten-1.1.4.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9265100a0153598fe2514c45a1f058e92b45d1fa06e142a80bda2587b38ceea1
|
|
BLAKE2b-256 checksum How to use checksums |
b3aac5dadb095e9a8240a8e33135f0f59020e1a374fe352a4216fbd9b649d835
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pymaskinporten-1.1.4-py3-none-any.whl
| Download URL | pymaskinporten-1.1.4-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76c9f344d301348fb37155302b58971f2265036db0c45469d234debba308b2c7
|
|
BLAKE2b-256 checksum How to use checksums |
33304f9054c3c112f05da72e616344f6a7c16607495f5416f6185b789d6d4574
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|