首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Microsoft365R错误连接到共享点

使用Microsoft365R错误连接到共享点
EN

Stack Overflow用户
提问于 2022-02-11 08:06:41
回答 1查看 328关注 0票数 0

我试图连接到sharepoint,使用包Microsoft365R在无人值守的R脚本中加载excel文件

我在Azure中创建了这个应用程序,并给它分配了权限。我已经能够成功地连接到用户onedrive并列出其中的文件。

起作用的代码

代码语言:javascript
复制
library(AzureGraph)
library(Microsoft365R)

tenant <- "your-tenant-here"

# the application/client ID of the app registration you created in AAD
# - not to be confused with the 'object ID' or 'service principal ID'
app <- "your-app-id-here"

# retrieve the client secret (password) from an environment variable
pwd <- Sys.getenv("EXAMPLE_MS365R_CLIENT_SECRET")

# retrieve the user whose OneDrive we want to access
# - this should be their 'userPrincipalName', which is of the form 'name@tenant.com'
# - note this may be different to their regular email address
user <- Sys.getenv("EXAMPLE_MS365R_TARGET_USER")

# create a Microsoft Graph login
gr <- create_graph_login(tenant, app, password=pwd, auth_type="client_credentials")

drv <- gr$get_user(user)$get_drive()

drv$list_files()

当运行下面的代码时,我会得到错误

代码语言:javascript
复制
# the application/client ID of the app registration to use
app <- "your-app-id-here"

# get the service account username and password
user <- Sys.getenv("EXAMPLE_MS365R_SERVICE_USER")
pwd <- Sys.getenv("EXAMPLE_MS365R_SERVICE_PASSWORD")

# SharePoint site and path to folder
sitename <- Sys.getenv("EXAMPLE_MS365R_SPO_SITENAME")
folderpath <- Sys.getenv("EXAMPLE_MS365R_SPO_FOLDERPATH")

# use the 'resource_owner' auth type for a non-interactive login
site <- get_sharepoint_site(sitename, tenant=tenant, app=app, username=user, password=pwd,
    auth_type="resource_owner")

输出:

代码语言:javascript
复制
Error in process_aad_response(res) : 
  Unauthorized (HTTP 401). Failed to obtain Azure Active Directory token. Message:
AADSTS7000218: The request body must contain the following parameter: 'client_assertion' or 'client_secret'.

该函数似乎没有客户端机密的参数。

我注意到了一揽子计划中的一些小插曲,但我一定是遗漏了什么。有人能提供援助吗?

资源https://cran.r-project.org/web/packages/Microsoft365R/vignettes/scripted.html

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-17 16:20:27

当您试图为没有AADSTS7000218参数的具有“client_secret”平台配置的应用程序获取身份验证令牌时,您将得到client_secret错误。

当应用程序的平台配置到Mobile and desktop applications时如何?

要更改平台配置,请执行以下操作:

从Azure AD上的configuration.

  • Open页面打开应用程序,并打开Manage - Authentication页面。

  • 删除现有的Web平台Add a platform并选择Mobile and desktop applications.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71076876

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档