이것이 내가하는 일입니다.작업 계정을 사용하여 Office 365의 일정에 액세스 할 수 없습니다.
Microsoft Azure를 통해 Microsoft Graph API를 사용하여 Office 365 테넌트의 일정에 액세스하고 관리 할 수있는 응용 프로그램을 개발하고 싶습니다. 이 회사는 10 명의 사용자를 가진 365 개의 사무실과 Azure Active Directory에 대한 액세스 권한을 가지고 있습니다. 저는 파이썬 3.5를 사용 중이며 라이브러리에 레이아웃을 요청합니다 인증 코드 부여 흐름.
Windows Azure Active Directory에 내 응용 프로그램을 등록하고이 응용 프로그램에 필요한 모든 액세스 권한과 응답 URL을 제공했습니다. 고객 비밀 키도 발급되었습니다. 토큰
을 받고, 둘째def triggerAutorization(request):
state = str(uuid4())
payload = {
"client_id": client_id,
"response_type": "code",
"state": state,
"redirect_uri": "http://localhost:8000/authorized",
"prompt": "consent"
}
url = "https://login.microsoftonline.com/{tenant}/oauth2/authorize?" + urllib.parse.urlencode(payload)
return HttpResponseRedirect(url)
다음 Autorization 코드를 받고, 첫째
: 여기 https://graph.microsoft.io/en-us/docs/authorization/app_authorization
, 내가 다음 과정 :
나는 다음과 같은 링크를 읽어def requestToken(request):
headers = { 'Content-Type' : "application/x-www-form-urlencoded"}
post_data = {
"client_id": client_id,
"client_secret": client_secret,
"code" : request.session['code'],
"redirect_uri" : "http://localhost:8000/authorized",
"grant_type": "authorization_code",
"resource": "https://graph.microsoft.com/"
}
raw_response = requests.post("https://login.microsoftonline.com/{tenant}/oauth2/token?", data=post_data, headers= headers)
json_response = raw_response.json()
if json_response['access_token']:
request.session['access_token'] = json_response['access_token']
return HttpResponseRedirect('/createquote')
이 괜찮
셋째, 모든 것을, 나는 액세스 일정에 대한 권리 (내 생각)과 토큰 따라 액세스를 가지고 :
'scope': 'Calendars.Read Calendars.Read.All Calendars.Read.Shared Calendars.ReadWrite Calendars.ReadWrite.All Contacts.Read.Shared Directory.AccessAsUser.All Directory.Read.All Files.Read Files.Read.All Files.Read.Selected Files.ReadWrite Files.ReadWrite.All Mail.Read Mail.ReadWrite.All Mail.Send Mail.Send.All openid profile User.Read User.Read.All User.ReadBasic.All',
'expires_on': '1485932306',
'refresh_token': 'AQAB..',
'resource': 'https://graph.microsoft.com/',
'token_type': 'Bearer',
'expires_in': '3600',
'ext_expires_in': '0',
'not_before': '1485928406',
'access_token': 'eyJ0...',
'id_token': 'eyJ0...'
넷째, 문제는 여기에 온다, 내가 API 호출을 할 때, 응답이 의미있는 세부 사항없이 500 서버 오류이기 때문입니다.
def getCalendarList(request):
token = request.session['access_token']
headers = {
'User-Agent' : 'pythoncontacts/1.2',
'Authorization' : 'bearer {0}' . format(token),
'Content-Type' :"application/json;odata.metadata=minimal;odata.streaming=true"
}
request_id = str(uuid.uuid4())
instrumentation = { 'client-request-id' : request_id,
'return-client-request-id' : 'true' }
headers.update(instrumentation)
raw_response = requests.get("https://graph.microsoft.com/v1.0/me/calendars", headers = headers)
json_response = raw_response.json()
return HttpResponse(" %s" %str(json_response))
재미있는 것은, 내가 "https://graph.microsoft.com/v1.0/me/"와 API 호출을 변경할 때 작동한다는 것입니다.
커뮤니티, 저를 도와주세요. 나는 수 많은 문서를 읽고 다른 접근법을 시도해 보았습니다. 그러나 나는 이것을 작동시킬 수 없었습니다.
많은 감사의 말씀입니다.
많은 관심 부탁드립니다.
이 사용자의 기본 캘린더는 https://outlook.offfice365.com에서 볼 수 있습니까? 또한 비즈니스 라이센스가 있거나 Exchange Online을 사용하고 있는지 여부에 대한 설명이 명확하지 않습니다. –
Marc LaFleur에게 감사드립니다. !! !! :-) –