简体   繁体   English

将 OAuth 2 与桌面 c# 应用程序一起使用

[英]Using OAuth 2 with desktop c# Application

I never used oauth before, so i wanted my app to open a url on system's default browser, then the user logs in, authorize, etc etc and then i need to send back the authorization code to my application, is there a way to do it?我以前从未使用过 oauth,所以我希望我的应用程序在系统的默认浏览器上打开一个 url,然后用户登录、授权等,然后我需要将授权码发送回我的应用程序,有没有办法做它? i'm using Trakt's API .我正在使用Trakt 的 API

There are multiple options, here are some of them:有多种选择,以下是其中一些:

  • use a custom URL scheme for a callback URL, eg "myapp://callback/after/oauth";为回调 URL 使用自定义 URL 方案,例如“myapp://callback/after/oauth”;
  • deliver authorization code inside of the browser title and watch the browser window title from your application;在浏览器标题中传递授权码,并从您的应用程序中观看浏览器窗口标题;
  • temporary start a webserver from within your application and use a callback URL " http://localhost:port/ ".从您的应用程序中临时启动网络服务器并使用回调 URL“ http://localhost:port/ ”。

Google recommends #2 and #3 for desktop applications. Google 建议将 #2 和 #3 用于桌面应用程序。 #1 is normally used for mobile: https://developers.google.com/accounts/docs/OAuth2InstalledApp #1 通常用于移动设备: https : //developers.google.com/accounts/docs/OAuth2InstalledApp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM