Uppy集成OneDrive时缺失client_id参数报错的解决咨询
问题
使用Uppy的OneDrive插件时触发以下错误:
AADSTS900144: The request body must contain the following parameter: 'client_id'.
但手动构造如下GET请求可正常完成授权:
GET https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope}&response_type=code&redirect_uri={redirect_uri}
尝试用uppy.setMeta添加client_id但未生效,请问如何在请求中正确传入client_id?当前使用的代码如下:
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="robots" content="noindex"> <title>Uppy</title> <link href="https://releases.transloadit.com/uppy/v1.27.0/uppy.min.css" rel="stylesheet"> </head> <body> <div id="drag-drop-area"></div> <script src="https://releases.transloadit.com/uppy/v1.27.0/uppy.min.js"></script> <script> var uppy = Uppy.Core() .use(Uppy.Dashboard, { inline: true, target: '#drag-drop-area' }) .use(Uppy.GoogleDrive, {target: Uppy.Dashboard, companionUrl: 'http://localhost:3020'}) .use(Uppy.Dropbox, {target: Uppy.Dashboard, companionUrl: 'http://localhost:3020'}) .use(Uppy.OneDrive, {target: Uppy.Dashboard, companionUrl: 'http://localhost:3020'}) uppy.setMeta({ "client_id": "some_id" }) uppy.on('complete', (result) => { console.log('Upload complete! We’ve uploaded these files:', result.successful) }) </script> </body> </html>
解决方法
uppy.setMeta用于设置文件元数据,无法配置第三方服务的认证参数,因此用它传递client_id不会生效。正确做法是在初始化OneDrive插件时,将client_id作为配置项传入:
.use(Uppy.OneDrive, { target: Uppy.Dashboard, companionUrl: 'http://localhost:3020', clientId: 'your_actual_client_id' // 替换为你的真实client_id })
补充注意事项:
- 若使用Uppy Companion(已配置
companionUrl),需在Companion的配置文件中同时添加OneDrive的client_id和client_secret,否则Companion无法完成后续的Token交换流程。 - 确认Azure AD中已为该
client_id配置正确的重定向URI,且与Companion或Uppy设置的重定向地址一致。
内容的提问来源于stack exchange,提问作者Tony
相关产品推荐
相关产品推荐

