В Azure Active Directory, у меня есть приложение, которое требует использования MicrosoftGraphAPI и SharePointAPI со следующими областями:
GraphAPI scopes:
"https://graph.microsoft.com/User.Read.All", "https://graph.microsoft.com/Group.Read.All", "https://graph.microsoft.com/Sites.Read.All", "https://graph.microsoft.com/Calendars.Read.Shared", "https://graph.microsoft.com/MailboxSettings.Read", "https://graph.microsoft.com/Files.Read.All"
SharePointAPI scopes:
"https://microsoft.sharepoint-df.com/AllSites.Read", "https://microsoft.sharepoint-df.com/AllSites.FullControl", "https://microsoft.sharepoint-df.com/User.Read.All"
Я пытаюсь получить токен для приложения:
from msal import PublicClientApplication AUTHORITY = 'https://login.microsoftonline.com/common' scopes = [ "https://microsoft.sharepoint-df.com/AllSites.Read", "https://microsoft.sharepoint-df.com/AllSites.FullControl", "https://microsoft.sharepoint-df.com/User.Read.All" "https://graph.microsoft.com/User.Read.All", "https://graph.microsoft.com/Group.Read.All", "https://graph.microsoft.com/Sites.Read.All", "https://graph.microsoft.com/Calendars.Read.Shared", "https://graph.microsoft.com/MailboxSettings.Read", "https://graph.microsoft.com/Files.Read.All" ] app = PublicClientApplication(client_id, authority=AUTHORITY) flow = app.initiate_device_flow(scopes=scopes)
Но после утверждения приложения в WebUI я получаю следующую ошибку:
'error_description': 'AADSTS28000: Provided value for the input parameter scope is not valid because it contains more than one resource. Scope https://graph.microsoft.com/Calendars.Read.Shared https://graph.microsoft.com/Files.Read.All https://graph.microsoft.com/Group.Read.All https://graph.microsoft.com/MailboxSettings.Read https://graph.microsoft.com/Sites.Read.All https://graph.microsoft.com/User.Read.All https://microsoft.sharepoint-df.com/AllSites.FullControl https://microsoft.sharepoint-df.com/AllSites.Read https://microsoft.sharepoint-df.com/User.Read.All offline_access openid profile is not valid'
Это ожидаемое поведение. Вы не можете смешивать ресурсы (graph, sharepoint и т. Д. c), но вы можете получить 1 токен доступа для каждого дополнительного ресурса, используя тот же refre sh token .
. Вы можете достичь этого в MSAL вызывается следующий метод :
PublicClientApplication.AcquireTokenByRefreshToken(IEnumerable<string> scopes, string refreshToken);