来自Android应用的执行API的权限失败 [英] Permissions failure with Execution API from Android app

查看:157
本文介绍了来自Android应用的执行API的权限失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以成功获取执行API快速入门

a>来访问文件名。



但增加快速启动脚本以使用电子表格功能会触发类型为未发现验证问题的错误。



添加 DriveApp.getFilesByName()不会导致任何权限问题,它是 SpreadsheetApp的添加。 create()触发错误。保存增强脚本会生成一条消息,指出脚本需要额外的权限。我已经尝试过:


  • 创建/保存一个新的/完整的脚本,因此所有必需的权限都是通过第一个脚本实例建立

  • 删除目标上的应用程序数据以强制授予新的权限

  • 删除目标上的应用程序以强制新的权限被授予

  • 重新生成新的SHA1密钥并使用新密钥重新认证以重新启动权限授予流程





我的代码:

 函数getFoldersUnderRoot(){
var my_ss =SDRP-Log-Test;
var my_sheet =month;
var files = DriveApp.getFilesByName(my_ss);
var file =!files.hasNext()? SpreadsheetApp.create(my_ss):files.next();
var ss = SpreadsheetApp.openById(file.getId());

var root = DriveApp.getRootFolder();
var folders = root.getFolders();
var folderSet = {};
while(folders.hasNext()){
var folder = folders.next();
folderSet [folder.getId()] = folder.getName();
}
return folderSet;
}

我已经独立验证了电子表格脚本可以通过开发接口正常工作,所以脚本的工作。
$ b

build.gradle

  defaultConfig {
applicationIdcom.jackb.sdrp
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName1.0
}

开发平台:




  • 主机:Win10& Android Studio 1.4(当前修补程序)



目标:


  • Samsung Galaxy S2& Android 4.1.2

  • 三星Galaxy S5& Android 5.1.1 通过添加SpreadsheetApp调用,您已经修改了所需的认证范围。
  • 为您的脚本。您需要更新您的范围以包含Spreadsheets。


    要使用API​​,您必须提供有效的OAuth令牌,覆盖脚本使用的所有范围(不仅仅是所使用的范围由被调用的函数)。要找到要包含在认证令牌中的正确范围,请在脚本编辑器中打开该项目,然后选择文件>项目属性,然后单击范围选项卡。 < a href =https://developers.google.com/apps-script/guides/rest/api =nofollow> ref



    I am able to successfully get the Execution API Quickstart to work for accessing filenames.

    But augmenting the Quickstart script to use Spreadsheet functions triggers an error of type "No authentication challenges found".

    The addition of DriveApp.getFilesByName() does not cause any permissions problems, it is the addition of SpreadsheetApp.create() that triggers the error. Saving the augmented script generates a message that the script requires additional permissions. I have tried:

    • creating/saving a new/complete script so all required permissions are established with the first script instantion
    • deleting the app data on the target to force new permissions to be granted
    • deleting the app on the target to force new permissions to be granted
    • regenerating a new SHA1 key and re-credential-ing with the new key to re-initiate the permission granting process

    My code:

    function getFoldersUnderRoot() {
      var my_ss = "SDRP-Log-Test";
      var my_sheet = "month";
      var files = DriveApp.getFilesByName(my_ss);
      var file = !files.hasNext() ? SpreadsheetApp.create(my_ss) : files.next();
      var ss = SpreadsheetApp.openById(file.getId());
    
      var root = DriveApp.getRootFolder();
      var folders = root.getFolders();
      var folderSet = {};
      while (folders.hasNext()) {
        var folder = folders.next();
        folderSet[folder.getId()] = folder.getName();
      }
      return folderSet;
    }
    

    I have independently verified that the Spreadsheet scripting works correctly via the development interface, so the scripting works.

    build.gradle:

    defaultConfig {
        applicationId "com.jackb.sdrp"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    

    Development platform:

    • Host: Win10 & Android Studio 1.4 (Current patching)

    Target:

    • Samsung Galaxy S2 & Android 4.1.2
    • Samsung Galaxy S5 & Android 5.1.1

    解决方案

    By adding SpreadsheetApp calls, you've modified the authentication scope required for your script. You need to update your scope to include Spreadsheets.

    To use the API, you must supply a valid OAuth token that covers all the scopes used by the script (not just the ones used by the called function). To find the correct scopes to include in the authentication token, open the project in the script editor, then select File > Project properties and click the Scopes tab.ref

    这篇关于来自Android应用的执行API的权限失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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