【发布时间】:2016-05-05 19:36:11
【问题描述】:
我的问题是,当我尝试使用 Phonegap 应用程序从 Dropbox 获取 access_token 时,出现以下错误:
不允许加载本地资源:file:///android_asset/www/index.html#access_token={MY_ACCESS_TOKEN}&token_type=bearer&state=%3CCSRF+token%3E&uid=130101032
document.addEventListener("deviceready", onDeviceReadyLoginDropbox, false);
function onDeviceReadyLoginDropbox() {
var url = document.URL,
shortUrl=url.substring(0,url.lastIndexOf("/"));
console.log(cordova.InAppBrowser);
var ref = cordova.InAppBrowser.open('https://www.dropbox.com/1/oauth2/authorize?client_id={APP_KEY}&response_type=token&redirect_uri='+shortUrl+'/index.html&state=%3CCSRF%20token%3E', "_blank");
}
所以,一切正常,但重定向不是这样,这里的解决方法是什么?我读到使用 JS 你无法访问本地文件,那么当重定向不起作用时,我如何获得访问令牌?唯一的可能就是只使用 JS。
【问题讨论】:
标签: javascript cordova dropbox dropbox-api