μ΄ URLμμ (λΈλΌμ°μ λ₯Ό ν΅ν΄) μ‘μΈμ€ ν μμλ νμΌμ λ€μ΄λ‘λνλ €κ³ ν©λλ€.
https://test.sharepoint.com/sites/team/team documents / subfolder / document.docx
λ€μ μ½λμ ν¨κ» ClientRequest κ°μ²΄λ₯Ό μ¬μ©νκ³ μμ΅λλ€.
url = "https://test.sharepoint.com/sites/team"
username="[email protected]"
password="pass"
ctxAuth = AuthenticationContext(url)
if ctxAuth.acquire_token_for_user(username, password):
print 'authentication successful, proceeding...'
request = ClientRequest(ctxAuth)
requestUrl="{0}/_api/web/getfilebyserverrelativeurl('team documents/subfolder/document.docx')"
options=RequestOptions(requestUrl.format(url))
data = request.execute_query_direct(options)
μ΄κ²μ μ€ννλ©΄ λ€μκ³Ό κ°μ μΆμ μ μ»μ΅λλ€.
$ python test.py
No handlers could be found for logger "client.office365.runtime.auth.saml_token_provider.SamlTokenProvider.process_service_token_response"
authentication successful, proceeding...
Traceback (most recent call last):
File "test.py", line 14, in <module>
data = request.execute_query_direct(options)
File "/usr/lib/python2.7/site-packages/client/office365/runtime/client_request.py", line 77, in execute_query_direct
self.context.authenticate_request(request_options)
File "/usr/lib/python2.7/site-packages/client/office365/runtime/auth/authentication_context.py", line 20, in authenticate_request
request_options.set_header('Cookie', self.provider.get_authentication_cookie())
File "/usr/lib/python2.7/site-packages/client/office365/runtime/auth/saml_token_provider.py", line 65, in get_authentication_cookie
return 'FedAuth=' + self.FedAuth + '; rtFa=' + self.rtFa
TypeError: cannot concatenate 'str' and 'NoneType' objects
λͺ¨λμ μ¬μ©νλ λ°©λ²μ λ¬Έμ κ° μμ΅λκΉ?
SharePoint μΈμ€ν΄μ€κ° νλ‘μ λ€μμ μ€νλκΈ° λλ¬Έμ λΉμ·ν λ¬Έμ κ° λ°μνμ΅λλ€. λ‘κ·ΈμΈ URL ( self.sts
)κ³Ό μΏ ν€ μ΄λ¦μ μ¬μ μνκΈ° μν΄ SamlTokenProvider
λ₯Ό νμ ν΄λμ€λ‘ λ§λ€μ΄μΌνμ΅λλ€. λ¬Έμ λ μ΄κΈ°ν μ€μ μ½λκ° acquire_authentication_cookie
μ κ²°κ³Όλ₯Ό νμΈνμ§ μκΈ° λλ¬Έμ μΈμ¦μ μ€ν¨νλ©΄ μΏ ν€λ₯Ό μ¬μ©ν λκΉμ§ μ΄μ λν΄ λ£μ§ λͺ»νλ€λ κ²μ
λλ€.
λλ κ°μ λ¬Έμ μ λΆλͺμ³€λ€. μΈμ¦ μ€ν¨λ μμΈλ‘ μ²λ¦¬λμ§ μλ κ² κ°μ΅λλ€. μΏ ν€λ₯Ό 쿼리 ν λλ§ κ±°νμ΄ λ°μν©λλ€. μ격 μ¦λͺ νμΈ
κ°μ λ¬Έμ . μ격 μ¦λͺ μ νμΈνμ§λ§ λ¬Έμ κ° μ§μλ©λλ€. λ€λ₯Έ μκ°μ? κ°μ¬!
κ²°κ΅ OAuth2Session μ μ¬μ©νμ¬ oauth2 μΈμ¦μ λ°κ³ κ·Έλν APIμμ λ°μ΄ν°λ₯Ό κ°μ Έ μμ΅λλ€. μ€λλμκ³ λ μ΄μ μ νν μΈλΆ μ¬νμ κΈ°μ΅νμ§ λͺ»ν©λλ€.
κ°μ¬ν©λλ€.
μλ νμΈμ, λμΌν λ¬Έμ κ° μμ§λ§ μ κ²½μ°μλ FormAuthentication λ©μλλ‘ κ΅¬μ±λ SharePointκ° μκΈ° λλ¬Έμ΄λΌκ³ μκ°ν©λλ€. μ μ ν ν ν° κ³΅κΈμκ° κ΅¬ν λ λκΉμ§ μλνμ§ μμ΅λλ€.
μ΄ λ¬Έμ λ λ°μνμ§λ§ outlook.com κ³μ μ μ¬μ©νλ κ²½μ°μλ§ λ°μν©λλ€. λλ λκ΅°κ°κ° λ€μμ λ¬΄μ¨ μΌμ΄ μΌμ΄λκ³ μλμ§ μ€λͺ νκ³ μλ§λ ν΄κ²°μ± μ μ 곡 ν μ μκΈ°λ₯Ό λ°λλλ€. λ€μμ κ°λ¨ν μ€λͺ μ λλ€.
1) SharePoint μ¬μ΄νΈλ ν΄λΌμ°λμ μμ΅λλ€ (https://mn365.sharepoint.com).
2) λ―Έλ€μν μ£Ό μ격 μ¦λͺ
μ μ¬μ©νμ¬ μ¬μ΄νΈμ μ°κ²°νλ©΄ μ λλ‘ μ°κ²°λ©λλ€.
3)νμ§λ§ λ΄ μμ© νλ‘κ·Έλ¨μ λ΄ μμ μ μ격 μ¦λͺ
μ ν¬ν¨νκ³ μΆμ§ μκΈ° λλ¬Έμ " [email protected] "μ€μ λ°λΌ "μλΉμ€ κ³μ "μ λ§λ€μμ΅λλ€. μ΄ κ³μ μ μ€ν¨ν©λλ€.
outlook.com μ£Όμλ₯Ό μ¬μ©νλ κ²κ³Ό λ΄ μ‘°μ§μμ λ°κΈ ν μ£Όμ (μ΄ κ²½μ° firstName. [email protected]) λ₯Ό μ¬μ©νλ κ²μ μΈμ¦ μ°¨μ΄λ 무μμ λκΉ
μ¬κΈ°μλ κ°μ λ¬Έμ κ° μμ΅λλ€. μΈμ¦μ μν΄ AD FSλ₯Ό μ¬μ©νκ³ μμ΅λλ€. μ§κΈκΉμ§λ SharePoint μ¨λΌμΈ μλ²μμ μ 보λ₯Ό μ»μ μμλ λ°©λ²μ μ°Ύμ§ λͺ»νμ΅λλ€. λ§μ λΌμ΄λΈλ¬λ¦¬λ₯Ό μλνμ§λ§ μ무κ²λ ν¨κ³Όκ° μμμ΅λλ€.
Sharepointκ° μΈμ¦μ μν΄ μ¨ νλ λ―Έμ€ STS / ADFSλ‘ λ¦¬λλ μ νκΈ° λλ¬Έμ λμΌν μ€λ₯κ° λ°μνμ΅λλ€.
O365μμ μ§μ μ O365 μ¬μ©μλ₯Ό λ§λ€μμΌλ―λ‘ μ¨-νλ λ―Έμ€ STS / ADFS λ‘μ 리λλ μ μ μ¬μ©νμ§ μμ΅λλ€. μ΄κ²μ μ€λ₯λ₯Ό ν΄κ²°νμ΅λλ€ π
λλ ootbλ₯Ό μ€ννκ³ λ΄ μ‘°κ±΄μ λ€λ£¨λ sharepyλ‘ μ ννμ΅λλ€.
μ¬κΈ°μμ λμΌ :
λ‘κ±° "office365.runtime.auth.saml_token_provider.SamlTokenProvider._process_service_token_response"μ λν μ²λ¦¬κΈ°λ₯Ό μ°Ύμ μ μμ΅λλ€.
λ€λ₯Έ μ¬λμκ² νμ΄μ΄ μμ΅λκΉ?
λ€μμ λ²μλ₯Ό λ μ’νλ λ° λμμ΄ λ μ μμ΅λλ€.
μΌλ° SharePoint URLμμλ μ±κ³΅μ μΌλ‘ μΈμ¦ ν μ μμ§λ§ νΉμ ν μ±λμ κ°λ¦¬ν€λ URLμμλ μΈμ¦ ν μ μμ΅λλ€. λ€μ μ½λλ μ μλν©λλ€.
url = "https://COMPANYNAME.sharepoint.com/"
username=raw_input("username: ")
password=raw_input("password: ")
ctx_auth = AuthenticationContext(url=url)
if ctx_auth.acquire_token_for_user(username=username, password=password):
νμ§λ§ URLμ λ€μμΌλ‘ λ°κΏ λ :
url = "https://COMPANYNAME.sharepoint.com/sites/TEAMSCHANNEL/"
κ·Έλ° λ€μ λ€μ μ€λ₯κ° λ°μν©λλ€. :
No handlers could be found for logger "office365.runtime.auth.saml_token_provider.SamlTokenProvider.acquire_authentication_cookie"
λͺ¨λ ν΄κ²° λ°©λ²μ΄ κ°μ¬ν©λλ€. λ΄ λΈλΌμ°μ μμ λ λ€ μ λ³Ό μ μμ΅λλ€.
μμ μ¬μ© μ¬λ‘μ λν ν΄κ²° λ°©λ²μ μ°Ύμμ΅λλ€. AuthenticationContext
λ₯Ό μ»μΌλ €λ©΄ κΈ°λ³Έ URLμ μ¬μ©νμμμ€. λ€λ₯Έ URLμ μ¬μ©νμ¬ μ ClientContext
κ°μ²΄λ₯Ό λ§λ€ μ μμ΅λλ€.
base_url = "https://COMPANYNAME.sharepoint.com/"
ctx_auth = AuthenticationContext(url=base_url)
if not ctx_auth.acquire_token_for_user(username=user, password=password):
sys.exit('Error in getting token - quitting')
url = base_url + "sites/TEAMSCHANNEL/"
ctx = ClientContext(url, ctx_auth)
..
..
μλ€ μ!
μ΄ λ¬Έμ κ°λ³΄κ³ λ μ΄ν μ§κΈκΉμ§ _SharePoint Onlineμ μ¬μ©ν SAML κΈ°λ° νλλ μ΄μ μΈμ¦ μ§μ _ μΈ‘λ©΄μμ λ€μκ³Ό κ°μ κ°μ / λ²κ·Έ μμ μ΄ μ΄λ£¨μ΄μ‘μ΅λλ€.
λ°λΌμ μ 곡λ μ€λ₯κ° λ μ΄μ λ°μνμ§ μμμΌν©λλ€. _latest_ λ²μ ( 2.1.10.1
μ΄μ)μ νμΈνμμμ€.
κ°μ₯ μ μ©ν λκΈ
SharePoint μΈμ€ν΄μ€κ° νλ‘μ λ€μμ μ€νλκΈ° λλ¬Έμ λΉμ·ν λ¬Έμ κ° λ°μνμ΅λλ€. λ‘κ·ΈμΈ URL (
self.sts
)κ³Ό μΏ ν€ μ΄λ¦μ μ¬μ μνκΈ° μν΄SamlTokenProvider
λ₯Ό νμ ν΄λμ€λ‘ λ§λ€μ΄μΌνμ΅λλ€. λ¬Έμ λ μ΄κΈ°ν μ€μ μ½λκ°acquire_authentication_cookie
μ κ²°κ³Όλ₯Ό νμΈνμ§ μκΈ° λλ¬Έμ μΈμ¦μ μ€ν¨νλ©΄ μΏ ν€λ₯Ό μ¬μ©ν λκΉμ§ μ΄μ λν΄ λ£μ§ λͺ»νλ€λ κ²μ λλ€.