javascript - Windows Phone 8.1 上的 JS OAuth 2.0

标签 javascript windows-phone-8.1

因此,我正在尝试为 Windows Phone 创建一个 Gitter 客户端,为此我需要在其 API 上使用 Bearer OAuth。此过程似乎会导致重定向到 gitter 网页(以获取访问 token ),然后重定向到我的应用程序指定的网页。但是显然APP不是网页,那么我应该如何获取返回的临时访问 token 来使用API​​?

我读过一些关于使用 ms-app://<security identifier> 的内容但这一切都非常模糊,几乎没有信息似乎是关于在不使用 c# 的情况下使用它的信息。 ,但这不是我要找的。

任何帮助将不胜感激!

编辑我刚刚注意到这里有人问这个问题 oAuth 2.0 in Windows Phone 8.1但还没有得到保证。抱歉,重复了。

最佳答案

好像它一直在我眼皮子底下!

您可以使用Windows.Security.Authentication.Web.WebAuthenticationBroker.authenticateAndContinue(startURI, endURI);

(文档主要是 c#,但这里: http://msdn.microsoft.com/en-us/library/dn631755.aspx )

  var redirect_uri = 'ms-app://<sid>';
  var client_id = '<client id>';

  // testing 
  var requestUri = new Windows.Foundation.Uri(
    'https://<site>/?client_id=' + client_id + '&redirect_uri=' + redirect_uri
  );

  Windows.Security.Authentication.Web.WebAuthenticationBroker.authenticateAndContinue(requestUri, Windows.Foundation.Uri(redirect_uri));

  app.addEventListener("activated", function (args) {
    if (args.detail.kind == activation.ActivationKind.webAuthenticationBrokerContinuation) {
      //take oauth response and continue login process
      console.log(args.detail.webAuthenticationResult);
    }
    //Handle normal activiation...(hidden)
  });

来源:http://blog.stevenedouard.com/andcontinue-methods-for-windows-universal-apps/

关于javascript - Windows Phone 8.1 上的 JS OAuth 2.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28651691/

相关文章:

javascript - Bigcommerce 的当前用户方法

javascript - QML:如何在自定义组件中触发onChanged?

javascript - (!value) 是否对所有假值都求值为真?

JavaScript 测试网络 worker

javascript:如何解析日期字符串

c# - WP增加全景重叠

xaml - 如何将 AppBarButton 图标添加到 Windows Phone 8.1 中的普通按钮?

c# - 使用 BottomAppBar 显示弹出窗口

xaml - Windows Phone 8.1 - 透视 header

c# - JSON.NET DeserializeObject 到对象列表