{"id":21228937,"url":"https://github.com/anthonycorletti/pypale","last_synced_at":"2025-07-10T15:31:35.116Z","repository":{"id":37945314,"uuid":"287093945","full_name":"anthonycorletti/pypale","owner":"anthonycorletti","description":"Python Passwordless Tokens.","archived":false,"fork":false,"pushed_at":"2024-04-29T21:48:08.000Z","size":31,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-01T16:41:45.965Z","etag":null,"topics":["jwt","passwordless-login","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anthonycorletti.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"anthonycorletti"}},"created_at":"2020-08-12T19:02:15.000Z","updated_at":"2024-06-10T23:56:58.172Z","dependencies_parsed_at":"2023-10-03T15:15:39.537Z","dependency_job_id":"d06ebbe3-2a0c-48f5-84df-4b7bf986fafd","html_url":"https://github.com/anthonycorletti/pypale","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonycorletti%2Fpypale","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonycorletti%2Fpypale/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonycorletti%2Fpypale/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonycorletti%2Fpypale/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anthonycorletti","download_url":"https://codeload.github.com/anthonycorletti/pypale/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225644529,"owners_count":17501539,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jwt","passwordless-login","python3"],"created_at":"2024-11-20T23:23:26.372Z","updated_at":"2024-11-20T23:23:26.947Z","avatar_url":"https://github.com/anthonycorletti.png","language":"Python","funding_links":["https://github.com/sponsors/anthonycorletti"],"categories":[],"sub_categories":[],"readme":"# pypale\n\n(Py)thon (Pa)ssword(le)ss Tokens.\n\n```sh\npip install pypale\n```\n\n## Usage\n\n```py\nfrom pypale import Pypale\n\ntoken_ttl_minutes = 14 * 24 * 60        # 2 weeks\ntoken_issue_ttl_seconds = 2 * 60 * 60   # 2 hours\nbase_url = \"mydomain.com\"\nsecret_key = \"loadthisfromyoursecretsmanager\"\n\npypale = Pypale(\n    base_url=base_url,\n    secret_key=secret_key,\n    token_ttl_minutes=token_ttl_minutes,\n    token_issue_ttl_seconds=token_issue_ttl_seconds)\n\nemail = \"jane.doe@example.com\"\ntoken = pypale.generate_token(email)\nassert pypale.valid_token(token, email)\n```\n\n## An example with SendGrid\n\n```py\n# send an email with a magic login link to \"jane.doe@example.com\"\nimport sendgrid\nfrom sendgrid.helpers.mail import Content, Email, Mail, To\n\nemail = \"jane.doe@example.com\"\ntoken = pypale.generate_token(email)\nlink = f\"https://mydomain.com/link_login/?code={token}\"\nsg = sendgrid.SendGridAPIClient(api_key=your_sendgrid_api_key)\nfrom_email = Email(\"bob@mydomain.co\")\nto_email = To(email)\nsubject = \"Hello!\"\ncontent = Content(\n            \"text/html\", f\"Click this \u003ca href={link}\u003elink\u003c/a\u003e to log in.\")\nmail = Mail(from_email, to_email, subject, content)\nresponse = self.sg.client.mail.send.post(request_body=mail.get())\nprint (response)\n\n# in your link_login route, mentioned in the link var above,\n# make sure to call pypale.validate_token with the token and\n# properly handle valid and invalid tokens.\n# for example ...\n\ndef link_login(code: str):\n    if not pypale.valid_token(code):\n        raise Exception(\"Invalid login.\")\n    access_token = base64.b64decode(code).decode(\"utf8\")\n    return {\n        \"access_token\": base64.b64decode(code).decode(\"utf8\"),\n        \"token_type\": \"bearer\"\n    }\n```\n\n### Contributions \u0026 Suggestions\n\n[Pull requests](https://github.com/anthcor/pypale/compare) and [issues](https://github.com/anthcor/pypale/issues/new) are very welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonycorletti%2Fpypale","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanthonycorletti%2Fpypale","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonycorletti%2Fpypale/lists"}