Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
调用OneDrive for Business REST API上载图像文件时出现问题_Rest_Api_Azure_Integration_Onedrive - Fatal编程技术网

调用OneDrive for Business REST API上载图像文件时出现问题

调用OneDrive for Business REST API上载图像文件时出现问题,rest,api,azure,integration,onedrive,Rest,Api,Azure,Integration,Onedrive,我在调用OneDrive for Business API工作时遇到了一个问题。以下是我一直遵循的步骤: 在Microsoft Azure Portal中创建了一个Web应用程序/API应用程序(一个非常棘手的过程)。已授予所有权限 从那里获得了应用程序ID(A_ID) 转到URL以通过浏览器获取“代码”: https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=&redirec

我在调用OneDrive for Business API工作时遇到了一个问题。以下是我一直遵循的步骤:

  • 在Microsoft Azure Portal中创建了一个Web应用程序/API应用程序(一个非常棘手的过程)。已授予所有权限
  • 从那里获得了应用程序ID(A_ID)
  • 转到URL以通过浏览器获取“代码”:

    https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=&redirect_uri=

  • 知道密码了。通过邮递员(使用代码、客户ID、客户机密和重定向URI)调用URL:
    https://login.microsoftonline.com/common/oauth2/token

  • 收到访问令牌(AT)和其他详细信息

  • 现在,当我想用这个在上传文件,我得到的错误。URI是:
    https:///_api/v2.0/me/drive/root:/Abc.txt:/content
    。对于标题,我传递:
    Authorization->Bearer AT;内容类型->应用程序/八位字节流

  • 错误是:

    {“error”:{“code”:“unauthenticated”,“message”:“Token包含无效签名”,“innerror”:{“code”:“invalidSignature”}}}


    我不知道问题在哪里。是在我使用的租户名称中(可能是我用错了!),还是在权限中,或者我没有在Azure门户中正确设置应用程序,或者是完全不同的内容。

    获取访问令牌时使用的
    资源是什么?这个API似乎有点复杂:。您检查过Microsoft Graph API吗?我认为它提供了一个更容易访问OneDrive for Business的平台。您需要添加必要的委托权限来访问MS Graph API中的用户文件,然后使用
    资源=https://graph.microsoft.com
    在您向/token请求获取访问令牌时。@juunas For MS Graph API,它表示首先注册应用程序。在这里,我无法登录OneDrive for Business帐户。但是,我可以通过此登录并为personal OneDrive创建应用程序。这里的要求是与OneDrive for Business集成。您可以使用该门户或Azure门户。这就是新的v2门户。这取决于您是否使用个人MS帐户或注册应用程序的组织AAD帐户登录。但v2应用程序也可以通过MS Graph API使用OneDrive for Business。@juunas我可以生成访问令牌。问题是,我无法使用它。每当我调用以上载文件时,都会出现错误:
    {“error”:{“code”:“unauthenticated”,“message”:“Token包含无效签名”,“innerError”:{“code”:“invalidSignature”}}
    。我正在调用以上载文件的URL是:
    [tenant]+/\u api/v2.0/me/drive/root:/Abc.txt:/content
    。这里的URL错误吗???是的,如果你使用我说的资源参数,你必须使用MS Graph API,而不是onedrive API