{"id":20862948,"url":"https://github.com/ymasaoka/sample-msal-python","last_synced_at":"2026-05-25T15:03:49.719Z","repository":{"id":124797162,"uuid":"480864627","full_name":"ymasaoka/Sample-MSAL-Python","owner":"ymasaoka","description":"A code collection using MSAL for Python.","archived":false,"fork":false,"pushed_at":"2024-02-26T16:00:04.000Z","size":54,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-19T08:14:04.393Z","etag":null,"topics":["azureactivedirectory","azuread","msal","msal-python","python","python3"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","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/ymasaoka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2022-04-12T15:18:53.000Z","updated_at":"2023-03-02T01:32:15.000Z","dependencies_parsed_at":"2024-11-18T05:29:16.546Z","dependency_job_id":"7b8618f1-01d8-4e92-95b6-5b3a677b1ad5","html_url":"https://github.com/ymasaoka/Sample-MSAL-Python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymasaoka%2FSample-MSAL-Python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymasaoka%2FSample-MSAL-Python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymasaoka%2FSample-MSAL-Python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymasaoka%2FSample-MSAL-Python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ymasaoka","download_url":"https://codeload.github.com/ymasaoka/Sample-MSAL-Python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243236380,"owners_count":20258825,"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":["azureactivedirectory","azuread","msal","msal-python","python","python3"],"created_at":"2024-11-18T05:26:56.177Z","updated_at":"2025-12-25T15:33:30.173Z","avatar_url":"https://github.com/ymasaoka.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sample-MSAL-Python\n本リポジトリは、MSAL for Python のサンプルコードを掲載しています。  \n本リポジトリにある各種コードは、Docker Compose を使用して簡単に実行できるようになっています。  \n\n# 実行環境準備\n\n## Docker コンテナーの起動\n本リポジトリをクローンし、ルートディレクトリに `web-variables.env` ファイルを作成します。  \n`web-variables.env` ファイルには、以下の情報を記載し、起動する Python コンテナーの環境変数として利用できるようにします。  \n\n```:web-variables.env\nCLIENT_ID={サービスプリンシパルのクライアント ID}\nCLIENT_SECRET={サービスプリンシパルのクライアントシークレット値}\nTENANT_ID={テナント ID}\nCLIENT_CERTIFICATION_PATH=./certs/{サービスプリンシパル認証時に SSL 証明書を使用する場合の秘密鍵ファイル}\nCLIENT_CERTIFICATION_THUMBPRINT={サービスプリンシパル認証時に SSL 証明書を使用する場合の thumbprint (拇印) 値}\n```\n\n`web-variables.env` ファイルを用意したら、Docker コンテナーを起動します。  \n\n```bash\ndocker compose up -d --build\n```\n\n## 自己署名証明書の作成\n\nサービスプリンシパルを利用する際の認証方式には、クライアントシークレットではなく証明書を利用することも可能です。  \n秘密鍵ありの SSL 証明書を サービスプリンシパルに登録し、MSAL for Python での接続時には、thumbprint と秘密鍵ファイルを使用します。\n\n証明書に、自己署名証明書を使用する場合は、以下を参考に自己署名証明書を作成してください。\n\n\u003e この例では、openssl を使用して作成しています。  \n\u003e 本リポジトリに記載のコードは、下記の手順で払い出した自己署名証明書を使用して動作確認をしたものになります。\n\n```bash\nopenssl genrsa 2024 \u003e ca-key.pem\nopenssl req -new -key ca-key.pem \u003e server.csr\nopenssl x509 -req -days {証明書が有効期限切れになるまでの日数} -signkey ca-key.pem \u003c server.csr \u003e server.crt\n```\n\n`ca-key.pem` が秘密鍵ファイル、`server.crt` が自己署名証明書 (SSL 証明書) です。  \n\n## サンプルコードの実行\n\n`sample` フォルダにある Python コードは、以下の形で実行が可能です。  \n\n```bash\ndocker compose run --rm app python3 servicePrincipal/{実行したい Python ファイル名}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymasaoka%2Fsample-msal-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fymasaoka%2Fsample-msal-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymasaoka%2Fsample-msal-python/lists"}