使用OAuth 2与桌面C#应用程序 [英] Using OAuth 2 with desktop c# Application

查看:125
本文介绍了使用OAuth 2与桌面C#应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从来没有使用OAuth的,所以我想我的应用程序打开系统默认浏览器的URL,然后在用户登录,授权,等等等等,然​​后我需要授权code送回我的应用程序,有没有办法做到这一点?我使用 Trakt的API

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? i'm using Trakt's API.

推荐答案

有多个选项,下面是其中一些:

There are multiple options, here are some of them:


  • 使用自定义URL方案的回调URL,例如的myapp://回调/后/ OAuth的;

  • 提供授权code中的浏览器标题内,并观看你的应用程序在浏览器窗口的标题; <​​/ li>
  • 临时从应用程序中启动Web服务器,并使用一个回调URL的http://本地主机:端口/

  • use a custom URL scheme for a callback URL, e.g. "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/".

谷歌建议#2,#3的桌面应用程序。 #1通常用于手机:
https://developers.google.com/accounts/docs/OAuth2InstalledApp

Google recommends #2 and #3 for desktop applications. #1 is normally used for mobile: https://developers.google.com/accounts/docs/OAuth2InstalledApp

这篇关于使用OAuth 2与桌面C#应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆