# 来自桌面应用程序（和基础域名网站）的授权

**URL:** https://meta.discourse.org/t/authorization-from-a-desktop-application-and-base-domain-site/134000
**Category:** Support
**Created:** [2019年十一月21日 06:47 UTC](https://meta.discourse.org/t/authorization-from-a-desktop-application-and-base-domain-site/134000 "2019-11-21T06:47:59Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2019年十一月21日 15:01 UTC](https://meta.discourse.org/t/authorization-from-a-desktop-application-and-base-domain-site/134000/2 "2019-11-21T15:01:35Z")

</div>

> [@tytel](#):
>
> 我在想，如果 Discourse 作为一个 OAuth2 提供商，这样行得通吗？我认为它目前不是，我也找不到实现我想要的功能的方法，但也许我遗漏了什么。

Discourse 目前无法作为 OAuth2 提供商（不过，我很期待有一天能看到实现这一功能的插件——这绝对是可行的）。

目前，您可以使用 Discourse 自带的 SSO 协议来实现这一功能。事实上，我们在 [discourse.org](http://discourse.org) 的内部工具中 routinely 使用这种方法：

> [@Use Discourse as an identity provider (SSO, DiscourseConnect)](https://meta.discourse.org/t/using-discourse-as-a-sso-provider/32974):
>
> So you want to use Discourse as an identity provider for your own web app? Great! Let’s get started. Enable [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) provider setting Under Discourse admin site settings (/admin/site\_settings) enable setting enable discourse connect provider and add a secret string to discourse connect provider secrets (used to hash SSO payloads). Implement [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) in your web app: Generate a random [nonce](https://en.wikipedia.org/wiki/Cryptographic_nonce). Let’s call this value NONCE. Save it temporarily so that you can verify it with the …

另一个选项（可能更适合“桌面应用程序”场景）是使用“用户 API 密钥”流程。我们在 Android/iOS 应用上正是通过这种方式对用户进行身份验证的：

> [@User API keys specification](https://meta.discourse.org/t/user-api-keys-specification/48536):
>
> Discourse contains a system for generating API keys per user if a very specific protocol is followed. This feature facilitates “application” access to Discourse instances without needing to involve moderators. High level description At a high level: Client (desktop app, browser plugin, mobile app) generates a private/public key pair and return url Client redirects to a route on discourse giving discourse its public key Discourse gets approval from user to use app Discourse generat…

---

_[View the full topic](https://meta.discourse.org/t/authorization-from-a-desktop-application-and-base-domain-site/134000)._
