简体   繁体   English

用户接受身份验证后,Dropbox无法转到上一页

[英]Dropbox cannot go to previous page after user accepts authentication

I am trying to write an html application which runs locally in my machine and store data in dropbox using its datastore api. 我正在尝试编写一个在我的计算机中本地运行的html应用程序,并使用其数据存储区api将数据存储在保管箱中。 The app will first authenticate the user with dropbox to loggin the user's account so that data can be stored. 该应用程序将首先使用保管箱对用户进行身份验证,以登录用户的帐户,以便可以存储数据。 (the related tutorial about this is https://www.dropbox.com/developers/datastore/tutorial/js ) (与此相关的教程是https://www.dropbox.com/developers/datastore/tutorial/js

However after I click the "allow" button in dropbox page to accept the authentication, I cannot go back to my html and get this error in my chrome js console: 但是,在我单击保管箱页面中的“允许”按钮接受身份验证之后,我无法返回html并在chrome js控制台中收到此错误:

Not allowed to load local resource: file:///I:/my%20app/my%20app.html# access_token=uKAmBGggAAA…bTSwy&token_type=bearer&uid=192028&state=oas_hjmjzi5m_0.8ejep9nuh99hpvi authorize?client_id=wy9s1uvip6qnswr&redirect_uri=file%3A///.................... 不允许加载本地资源:file:/// I:/my%20app/my%20app.html# access_token = uKAmBGggAAA…bTSwy&token_type = bearer&uid = 192028&state = oas_hjmjzi5m_0.8ejep9nuh99hpviauthorize?client_id = wy9s1uvip6q / uri / refile ....................

the js code of doing the authentication in my app is: 在我的应用中执行身份验证的js代码为:

function save(){
    var client = new Dropbox.Client({key: '9s1uswrxxxxxx'});
    client.authenticate({interactive: false}, 
        function (error) {
            if (error) {
                alert('Authentication error: ' + error);
            }
    });
    if (client.isAuthenticated()) {
        alert('the client is authenticated.');
    }
    client.authenticate();
    var datastoreManager = client.getDatastoreManager();
    datastoreManager.openDefaultDatastore(function (error, datastore) {
    if (error) {
        alert('Error opening default datastore: ' + error);
    }

According to dropbox datastore api tutorial: "The linking process will redirect the user to the Dropbox website and ask them to grant your app permission to access their Dropbox. When the user approves (or denies), they will be automatically directed back to the same page". 根据dropbox数据存储区api教程的说法:“链接过程会将用户重定向到Dropbox网站,并要求他们授予您的应用访问其Dropbox的权限。当用户批准(或拒绝)时,他们将被自动定向回同一用户页”。

So I would like to know why this error happens when goes back from dropbox authentication page to my HTML. 因此,我想知道为什么当从保管箱身份验证页面返回到我的HTML时会发生此错误。

Your redirect_uri is pointing at a local file:// URL which your browser won't redirect you to. 您的redirect_uri指向本地file:// URL,浏览器不会将您重定向到该URL。 See here for more information: 浏览此处获取更多信息:

https://forums.dropbox.com/topic.php?id=103530#post-558937 https://forums.dropbox.com/topic.php?id=103530#post-558937

In short, you should serve your app off of a server instead. 简而言之,您应该在服务器之外提供应用程序服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM