Office365-rest-python-client: https://mycompany.sharepoint.com/sites/documentssite//_vti_bin/idcrl.svcμ—μ„œ 인증 μΏ ν‚€λ₯Ό κ²€μƒ‰ν•˜λŠ” λ™μ•ˆ 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.

에 λ§Œλ“  2020λ…„ 08μ›” 05일  Β·  3μ½”λ©˜νŠΈ  Β·  좜처: vgrem/Office365-REST-Python-Client

μ•ˆλ…•ν•˜μ‹­λ‹ˆκΉŒ,

문제의 λ§₯락

μ €λŠ” 2.1.7.post1 버전(pip freeze에 따라)으둜 μž‘μ—… 쀑이며 μ…°μ–΄ν¬μΈνŠΈμ— λ‘œκ·ΈμΈν•˜λŠ” 데 MFAκ°€ ν•„μš”ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.
ν˜„μž¬ λ‹€μŒ 슀크립트(ν”„λ‘œμ νŠΈμ˜ READMEμ—μ„œ μž‘μ„±)λ₯Ό μ‚¬μš©ν•˜μ—¬ νšŒμ‚¬μ˜ μ…°μ–΄ν¬μΈνŠΈμ—μ„œ Excel νŒŒμΌμ„ κ°€μ Έμ˜€λ €κ³  ν•©λ‹ˆλ‹€.

from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.file import File

url = 'https://mycompany.sharepoint.com/sites/documentssite/'

ctx_auth = AuthenticationContext(url)
if ctx_auth.acquire_token_for_user(username, password):
    ctx = ClientContext(url, ctx_auth)
    web = ctx.web
    ctx.load(web)
    ctx.execute_query()
    print("Web title: {0}".format(web.properties['Title']))

이 슀크립트λ₯Ό μ‹€ν–‰ν•˜λ©΄ λ‹€μŒκ³Ό 같은 좜λ ₯이 μ œκ³΅λ©λ‹ˆλ‹€.
An error occurred while retrieving auth cookies from https://mycompany.sharepoint.com/sites/documentssite//_vti_bin/idcrl.svc

λ¬Έμ œμ— λŒ€ν•œ λͺ‡ 가지 세뢀정보

디버그 λͺ¨λ“œμ—μ„œ 이 슀크립트λ₯Ό μ‹€ν–‰ν•˜μ—¬ λ¬Έμ œκ°€ SamlTokenProvider 클래슀의 acquire_authentication_cookie λ©”μ„œλ“œμ—μ„œ λ°œμƒν•œλ‹€λŠ” 것을 μ•Œμ•˜μŠ΅λ‹ˆλ‹€.
μ‹€μ œλ‘œ λ©”μ„œλ“œλŠ” federated=True 둜 ν˜ΈμΆœλ˜λ―€λ‘œ HEAD λ©”μ„œλ“œλ₯Ό μ‚¬μš©ν•˜μ—¬ https://mycompany.sharepoint.com/sites/documentssite//_vti_bin/idcrl.svc μ—μ„œ HTTP μš”μ²­μ΄ μˆ˜ν–‰λ©λ‹ˆλ‹€. μ•„λž˜μ—μ„œ μ‹€νŒ¨ν•œ 뢀뢄을 찾을 수 μžˆμŠ΅λ‹ˆλ‹€.

     def acquire_authentication_cookie(self, security_token, federated=False):
        ...
        else:
            self._auth_cookies['SPOIDCRL'] = None
            session.head(self.__sts_profile.signInPageUrl,
                         headers={
                             'User-Agent': 'Office365 Python Client',
                             'X-IDCRL_ACCEPTED': 't',
                             'Authorization': 'BPOSIDCRL {0}'.format(security_token),
                             'Content-Type': 'application/x-www-form-urlencoded'
                         })
        logger.debug_secrets("session.cookies: %s", session.cookies)
        cookies = requests.utils.dict_from_cookiejar(session.cookies)
        logger.debug_secrets("cookies: %s", cookies)
        if not cookies:
            self.error = "An error occurred while retrieving auth cookies from {0}".format(self.__sts_profile.signInPageUrl)
            logger.error(self.error)
            return False

응닡에 μΏ ν‚€κ°€ ν¬ν•¨λ˜μ–΄ μžˆμ§€ μ•ŠμœΌλ―€λ‘œ λ©”μ‹œμ§€ 였λ₯˜κ°€ λ°œμƒν•©λ‹ˆλ‹€.

그건 κ·Έλ ‡κ³ , URL을 ' https://mycompany.sharepoint.com '으둜 μ„€μ •ν–ˆμ„ λ•Œλ„ 같은 λ¬Έμ œκ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.

λ¬Έμ œμ— λŒ€ν•œ 세뢀정보λ₯Ό μΆ©λΆ„νžˆ μ œκ³΅ν•˜μ§€ μ•Šμ€ 경우 μ•Œλ €μ£Όμ„Έμš”.
미리 κ°μ‚¬ν•©λ‹ˆλ‹€!

question

λͺ¨λ“  3 λŒ“κΈ€

λ¬Έμ œμ— λŒ€ν•œ λͺ‡ 가지 μ†Œμ‹:

λ‚˜λŠ”μ— HEAD μš”μ²­μ„ λ§Œλ“€ λ•Œ https://mycompany.sharepoint.com/sites/documentssite//_vti_bin/idcrl.svc 컬을, λ‚˜λŠ” λ¦¬λ””λ ‰μ…˜μžˆμ–΄ https://mycompany.sharepoint.com/_vti_bin/idcrl.svc/ (μ‘λ‹΅μ½”λ“œ : 307).

κ·Έλž˜μ„œ 이 링크에 HEAD μš”μ²­μ„ ν–ˆκ³ , Method Not Allowed 응닡을 λ°›μ•˜μŠ΅λ‹ˆλ‹€...
νšŒμ‚¬ μΈ‘μ—μ„œ λ¬Έμ œκ°€ μžˆλŠ” 것 같은데..

인사말!

제곡된 μ„ΈλΆ€ 정보에 κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€!

2.1.7.post1 λŠ” ν˜„μž¬ μ•½κ°„ κ΅¬μ‹μž…λ‹ˆλ‹€. λ‹€μ‹œ μ‹œλ„ν•΄ μ£Όμ„Έμš”. ν•˜μ§€λ§Œ _μ΅œμ‹ _ 버전(ν˜„μž¬ 2.1.10.1 을 μ‚¬μš©ν•˜λ©΄ GitHubλ₯Ό 톡해 λ‹€μš΄λ‘œλ“œν•  수 μžˆμŠ΅λ‹ˆλ‹€.

pip install git+https://github.com/vgrem/Office365-REST-Python-Client.git

λ˜λŠ” λŒ€μ²΄ μƒ‰μΈμ—μ„œ

κ·Έ μ΄ν›„λ‘œ 인증과 κ΄€λ ¨ν•˜μ—¬ λͺ‡ 가지 버그 μˆ˜μ •μ΄ ν•΄κ²°λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

λ‚˜λŠ” λ§ˆμ§€λ§‰ 버전을 μ„€μΉ˜ν–ˆκ³  잘 μž‘λ™ν•©λ‹ˆλ‹€! (μ‹€μ œλ‘œ ν’€κΈ°μ—λŠ” μ•„μ£Ό κ°„λ‹¨ν–ˆμ–΄μš”! :) )
λ„μ™€μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€ :D

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰