【发布时间】:2014-11-10 02:26:08
【问题描述】:
我已经获得了打印机列表,并通过此代码“Google Cloud Print using C#”向 Google 云打印提交了打印机作业,但我无法使用客户的 Google 密码访问他们的打印机。
现在我正在实施 oauth2 身份验证,并且我已经获得了测试帐户的日历和 Google 云打印的访问权限,但现在我不明白如何检索打印机列表以及如何使用此授权令牌发布打印机的作业.
对于 oauth2,我已经下载了这个示例并且运行良好“https://github.com/nanovazquez/google-calendar-sample”。
如果您有权使用 Google 云打印,只需在 _scopes 成员中添加“https://www.googleapis.com/auth/cloudprint”即可。
using System.Web;
using DotNetOpenAuth.OAuth2;
using Google.Apis.Authentication.OAuth2;
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
using Google.Apis.Calendar.v3;
using Google.Apis.Util;
namespace GoogleApiUtils
{
public static class GoogleAuthorizationHelper
{
private static string _clientId = ConfigurationManager.AppSettings["ClientId"];
private static string _clientSecret = ConfigurationManager.AppSettings["ClientSecret"];
private static string _redirectUri = ConfigurationManager.AppSettings["RedirectUri"];
private static string[] _scopes = new[] { CalendarService.Scopes.Calendar.GetStringValue(), "https://www.googleapis.com/auth/cloudprint" };
...
有没有人可以给我一些建议?
【问题讨论】:
-
欢迎来到 Stack Overflow。这不是在这里提问的好方法。到目前为止,您是否尝试过任何方法来解决您的问题?首先展示你的努力,这样人们就可以展示他们的努力。请先阅读FAQ、How to Ask 和help center。
-
我已经解决了。我创建了一个小项目,因此任何人都可以看到我是如何解决我的问题的,也许有人可以提供更好的解决方案。现在我要分享它。
标签: oauth-2.0 cloud token access-token printers