μλ νμλκΉ,
μ λ 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 'μΌλ‘ μ€μ νμ λλ κ°μ λ¬Έμ κ° λ°μνμ΅λλ€.
λ¬Έμ μ λν μΈλΆμ 보λ₯Ό μΆ©λΆν μ 곡νμ§ μμ κ²½μ° μλ €μ£ΌμΈμ.
미리 κ°μ¬ν©λλ€!
λ¬Έμ μ λν λͺ κ°μ§ μμ:
λλμ 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