问题描述
我们希望通过REST服务将文件上传到我们的oneDrive。在REST服务中,我们正在调用Microsoft Graph API,但我收到401错误,我猜是由于授权问题,我想知道这里最好的方法是什么?
如果在我们的Web应用程序上,整个过程将很好地工作。
我在Azure Active Directory门户中授予了App权限,并在处确认了同意
int betterReAlloc(void **pOldPtr,size_t newSz) {
void *newptr = realloc(*pOldPtr,newSz);
if (newPtr != NULL) *pOldPtr = newPtr)
return newptr != NULL;
}
char *ptr = somethingValidlyMalloced();
if (! betterReAlloc(&ptr,BETTER_SIZE)) {
puts("Cannot realloc,using original");
}
然后尝试获取令牌
https://login.microsoftonline.com/<tenant>/adminconsent?client_id=<client-id>
我仍然遇到401错误。
然后我固定了权限,现在我获得了access_token,现在我首先检查一个文件是否存在于oneDrive的特定文件夹中,如果不存在,则上传该文件。
但是现在我收到以下错误:
url = "https://login.microsoftonline.com/<tenant>/oauth2/v2.0/token"
"client_id": credential.clientid
"client_secret",credential.clientsecret
"scope","https%3A%2F%2Fgraph.microsoft.com%2F.default"
"grant_type","client_credentials"
我使用以下API检查文件是否存在:
{
"statuscode": 403,"body": "{\r\n \"error\": {\r\n \"code\": \"AccessDenied\",\r\n \"message\": \"Either scp or roles claim need to be present in the token.\",\r\n \"innerError\": {\r\n \"date\": \"2020-08-13T10:12:33\",\r\n \"request-id\": \"338a2758-m7e0-4289-bnna-45pb14c79efa\"\r\n }\r\n }\r\n}"
}
我不确定需要设置哪些角色/权限。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)