{"id":13507451,"url":"https://github.com/swelham/ueberauth_microsoft","last_synced_at":"2025-04-06T17:14:01.982Z","repository":{"id":20245493,"uuid":"83348981","full_name":"swelham/ueberauth_microsoft","owner":"swelham","description":"Microsoft Strategy for Überauth","archived":false,"fork":false,"pushed_at":"2024-04-15T15:50:07.000Z","size":152,"stargazers_count":35,"open_issues_count":5,"forks_count":33,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-23T11:17:22.033Z","etag":null,"topics":["azure-active-directory","azure-ad","elixir","microsoft","ueberauth"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/swelham.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2017-02-27T19:36:48.000Z","updated_at":"2024-05-01T15:27:39.941Z","dependencies_parsed_at":"2023-09-22T18:43:21.084Z","dependency_job_id":"52397238-0ca9-4cb8-820c-26031b9eb976","html_url":"https://github.com/swelham/ueberauth_microsoft","commit_stats":{"total_commits":95,"total_committers":16,"mean_commits":5.9375,"dds":0.6,"last_synced_commit":"87e2593b3c9dea1ce74f43c752088013b99e783b"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swelham%2Fueberauth_microsoft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swelham%2Fueberauth_microsoft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swelham%2Fueberauth_microsoft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swelham%2Fueberauth_microsoft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swelham","download_url":"https://codeload.github.com/swelham/ueberauth_microsoft/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247517922,"owners_count":20951719,"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":["azure-active-directory","azure-ad","elixir","microsoft","ueberauth"],"created_at":"2024-08-01T02:00:33.997Z","updated_at":"2025-04-06T17:14:01.963Z","avatar_url":"https://github.com/swelham.png","language":"Elixir","funding_links":[],"categories":["Authentication"],"sub_categories":[],"readme":"# Überauth Microsoft\n\n[![Module Version](https://img.shields.io/hexpm/v/ueberauth_microsoft.svg)](https://hex.pm/packages/ueberauth_microsoft)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/ueberauth_microsoft/)\n[![License](https://img.shields.io/hexpm/l/ueberauth_microsoft.svg)](https://github.com/swelham/ueberauth_microsoft/blob/master/LICENSE.md)\n[![Last Updated](https://img.shields.io/github/last-commit/swelham/ueberauth_microsoft.svg)](https://github.com/swelham/ueberauth_microsoft/commits/master)\n\n\u003e Microsoft OAuth2 strategy for Überauth.\n\nQuick start blog post: [Authenticating users with Microsoft OAuth](https://www.stuartwelham.com/articles/authenticating-users-with-microsoft-oauth)\n\n## Installation\n\n1.  Register an application in the Azure Portal ([see Microsoft tutorial for more info](https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app)).\n\n2.  Add `:ueberauth_microsoft` to your list of dependencies in `mix.exs`:\n\n    ```elixir\n    def deps do\n      [\n        {:ueberauth_microsoft, \"~\u003e 0.23\"}\n      ]\n    end\n    ```\n\n3.  Add the strategy to your applications:\n\n    ```elixir\n    def application do\n      [\n        applications: [:ueberauth_microsoft]\n      ]\n    end\n    ```\n\n4.  Add Microsoft to your Überauth configuration:\n\n    ```elixir\n    config :ueberauth, Ueberauth,\n      providers: [\n        microsoft: {Ueberauth.Strategy.Microsoft, []}\n      ]\n    ```\n\n5.  Update your provider configuration:\n\n    ```elixir\n    config :ueberauth, Ueberauth.Strategy.Microsoft.OAuth,\n      client_id: System.get_env(\"MICROSOFT_CLIENT_ID\"),\n      client_secret: System.get_env(\"MICROSOFT_CLIENT_SECRET\")\n    ```\n\n6.  Include the Überauth plug in your controller:\n\n    ```elixir\n    defmodule MyApp.AuthController do\n      use MyApp.Web, :controller\n      plug Ueberauth\n      ...\n    end\n    ```\n\n7.  Create the request and callback routes if you haven't already:\n\n    ```elixir\n    scope \"/auth\", MyApp do\n      pipe_through :browser\n\n      get \"/:provider\", AuthController, :request\n      get \"/:provider/callback\", AuthController, :callback\n    end\n    ```\n\n8.  Your controller needs to implement callbacks to deal with `Ueberauth.Auth`\n    and `Ueberauth.Failure` responses.\n\nFor an example implementation see the [Überauth Example](https://github.com/ueberauth/ueberauth_example) application.\n\n## Single Tenancy\n\nIf you are going to use your app only internally you may need to configure it for a single tenant.\nTo do so you only need to add `tenant_id` to your provider configuration like:\n\n```elixir\nconfig :ueberauth, Ueberauth.Strategy.Microsoft.OAuth,\n  tenant_id: System.get_env(\"MICROSOFT_TENANT_ID\"),\n  client_id: System.get_env(\"MICROSOFT_CLIENT_ID\"),\n  client_secret: System.get_env(\"MICROSOFT_CLIENT_SECRET\")\n```\n\n## Calling\n\nDepending on the configured url you can initial the request through:\n\n    /auth/microsoft\n\nBy default the scopes used are:\n\n- openid\n- email\n- offline_access\n- https://graph.microsoft.com/user.read\n\n_Note: at least one service scope is required in order for a token to be\nreturned by the Microsoft endpoint_\n\nYou can configure additional scopes to be used by passing the `extra_scopes`\noption into the provider:\n\n```elixir\nconfig :ueberauth, Ueberauth,\n  providers: [\n    microsoft: {\n      Ueberauth.Strategy.Microsoft,\n      [extra_scopes: \"https://graph.microsoft.com/calendars.read\"]\n    }\n  ]\n```\n\nIf you would like users to have the option to choose an alternate account to authenticate with instead of defaulting to the logged in account, you may pass the `prompt` option in to the provider (per [Microsoft documentation](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow)):\n\n```elixir\nconfig :ueberauth, Ueberauth,\n  providers: [\n    microsoft: {Ueberauth.Strategy.Microsoft, [prompt: \"select_account\"]}\n  ]\n```\n\n## Copyright and License\n\nCopyright (c) 2017 Stuart Welham\n\nReleased under the MIT License, which can be found in the repository in\n[LICENSE](./LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswelham%2Fueberauth_microsoft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswelham%2Fueberauth_microsoft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswelham%2Fueberauth_microsoft/lists"}