我试图连接到sharepoint,使用包Microsoft365R在无人值守的R脚本中加载excel文件
我在Azure中创建了这个应用程序,并给它分配了权限。我已经能够成功地连接到用户onedrive并列出其中的文件。
起作用的代码
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()当运行下面的代码时,我会得到错误
# 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")输出:
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
发布于 2022-03-17 16:20:27
当您试图为没有AADSTS7000218参数的具有“client_secret”平台配置的应用程序获取身份验证令牌时,您将得到client_secret错误。
当应用程序的平台配置到Mobile and desktop applications时如何?
要更改平台配置,请执行以下操作:
从Azure AD上的configuration.
Manage - Authentication页面。
Web平台Add a platform并选择Mobile and desktop applications.https://stackoverflow.com/questions/71076876
复制相似问题