在vkontakte api中授权Chrome应用程序作为独立应用程序 [英] authorize chrome app as standalone in vkontakte api

查看:180
本文介绍了在vkontakte api中授权Chrome应用程序作为独立应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  app.login = function()

我试图在chrome应用中使用vk.messages api, {
var link ='https://oauth.vk.com/authorize?'+
'client_id = 4837072'+
'& scope = friends,docs,status,messages, '+
'& redirect_uri ='+'https://oauth.vk.com/blank.html'+
'& display = popup'+
'& v = API_VERSION'+
'& response_type = token';
var width = 655;
var height = 539;
var left =(screen.width / 2) - (width / 2);
var top =(screen.height / 2) - (height / 2);
chrome.identity.launchWebAuthFlow({
'url':link,
'interactive':true
},function(redirect_url){
// redirect_url is undefined
console.log(redirect_url);
});
};

它需要以这种方式设置auth redirect_uri https://oauth.vk.com/ blank.html ,但 chrome.identity api 使用https://。 chromiumapp.org/。因此,vk auth窗口显示并重定向工作,但chrome无法确定auth重定向,并且不会使用重定向url进行回调。有没有其他的方式可以在Chrome应用程序中获得重定向url?

解决方案

嗯,我看到你要去哪里需要设置 redirect_uri 这种方式:


  redirect_uri = https://oauth.vk.com/blank.html 

这是强制性的描述说它们仅适用于桌面应用程序的方法的条件。


恐怕没有办法覆盖URL用于身份 API。



在这种情况下,你可以走相同的路线Silver Bird Twitter客户端:在目标地址注入一个内容脚本。从那里你可以提取所需的令牌。



编辑:我忘了你正在编写一个Chrome应用程序。然后,您应该尝试使用< webview> 及其脚本注入功能。
$ b 这意味着您必须在没有 chrome.identity 的帮助下做OAuth,但至少这是一个解决方案。


I'm trying to use vk.messages api in chrome app like this:

app.login = function () {
  var link = 'https://oauth.vk.com/authorize?' +
    'client_id=4837072' +
    '&scope=friends,docs,status,messages,notifications,' +
    '&redirect_uri=' + 'https://oauth.vk.com/blank.html' +
    '&display=popup' +
    '&v=API_VERSION' +
    '&response_type=token';
  var width = 655;
  var height = 539;
  var left = (screen.width / 2) - (width / 2);
  var top = (screen.height / 2) - (height / 2);
  chrome.identity.launchWebAuthFlow({
    'url': link,
    'interactive': true
  }, function (redirect_url) {
    // redirect_url is undefined
    console.log(redirect_url);
  });
};

It needs to set auth redirect_uri this way "https://oauth.vk.com/blank.html", but chrome.identity api uses "https://.chromiumapp.org/". So, vk auth window is showed and redirect works, but chrome can't determine auth redirect, and doesn't call back with redirect url. Is there any other way to get redirect url in chrome app?

解决方案

Well, I see where you're going with "it needs to set redirect_uri this way":

redirect_uri=https://oauth.vk.com/blank.html  

It is a mandatory condition for methods which descriptions say that they are available only for Desktop applications.

I'm afraid there is no way to override the URL used by identity API.

In this case, you can go kind of the same route Silver Bird Twitter client went: inject a Content Script in the target address. From there you can extract the tokens needed.

Edit: I forgot that you are writing a Chrome app. You should then try using <webview> and its script injection capabilities.

This means you'll have to do OAuth without help from chrome.identity yourself, but at least it's a solution.

这篇关于在vkontakte api中授权Chrome应用程序作为独立应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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