μλ νμλκΉ,
Office365-REST-Python-Clientλ₯Ό μ¬μ©νμ¬ μΈνΈλΌλ· Sharepoint ν¬νΈμ μ°κ²°νλ €κ³ νμ§λ§ AuthenticationContext ν΄λμ€μμ acquire_token_for_user()λ₯Ό νΈμΆνλ©΄ μ€ν¨ν©λλ€.
url = " https://mycompany.sharepoint.com "
ctx_auth = μΈμ¦ 컨ν μ€νΈ(URL)
ctx_auth.acquire_token_for_user("my_username", "my_password")
λ€μ μ€λ₯λ₯Ό νΈλ¦¬κ±°ν©λλ€.
AttributeError: 'NoneType' κ°μ²΄μ 'text' μμ±μ΄ μμ΅λλ€.
λ¬Έμ μΈμ¬,
νμ
λλ λκ°μ λ¬Έμ κ°μλ€
λ§μ°¬κ°μ§λ‘, μ΄κ²μ λ°©κΈ λνλ¬μΌλ©° λ μ΄μ 곡μ μ§μ μ μ‘μΈμ€ν μ μμ΅λλ€.
λμΌν λ¬Έμ κ° μμΌλ©° μν°νλΌμ΄μ¦ μ °μ΄ν¬μΈνΈμ μ‘μΈμ€ν μ μμ΅λλ€. λ€λ₯Έ λ¬Έμ (#76, 2018λ 8μ 5μΌ)μμ λ€μ μ루μ μ 보μ¬μ€λλ€(μμ§ μλνμ§ μμ).
_ν΄κ²°λμμ΅λλ€. λ¬Έμ λ Azure Active Directoryμ λ΄λΆ Active Directory κ°μ λΈλΌμ°μ λ₯Ό ν΅ν΄μλ§ κ²μ¬κ° μνλλ νμ¬ μ¬μ©μμ μ¬μ©μ΄μμ΅λλ€. λ°°μΉ μ€ν¬λ¦½νΈμ κ²½μ° ν΄λΌμ°λ AADμ μ¬μ©μλ₯Ό μμ±νμ΅λλ€._
μ¬μ€, λ΄ μ¬μ©μκ° AADμ μμ§λ§ μ¬μ ν μ‘μΈμ€ν μ μμ΅λλ€.(μ΄λ€ μ루μ /λ¨μ?
λ΄ μ½λκ° μλν©λλ€.
μ¬μ©μ μ΄λ¦ = 'λ΄ μ¬μ©μ μ΄λ¦'
λΉλ°λ²νΈ = 'λ΄ λΉλ°λ²νΈ'
ctx_auth.acquire_token_for_user(μ¬μ©μ μ΄λ¦=μ¬μ©μ μ΄λ¦, λΉλ°λ²νΈ=passWord)
μ μκ²λ ν¨κ³Όκ° μμ΅λλ€. URLμ " https://mycompany.sharepoint.com/sites/AnotherSite " λλ " https://mycompany.sharepoint.com/sites/AnotherSite/Subsite "μ κ°μ μλ μμ΅λλ€.
λμ λ€μ μ½λλ‘ μλν΄ λ³΄μΈμ.
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.runtime.client_request import ClientRequest
from office365.runtime.utilities.request_options import RequestOptions
user_credentials = {
'username' : '[email protected]',
'password' : 'my_password'
}
site_url = "https://mycompany.sharepoint.com/"
ctx_auth = AuthenticationContext(site_url)
if ctx_auth.acquire_token_for_user(user_credentials['username'], user_credentials['password']):
request = ClientRequest(ctx_auth)
options = RequestOptions("{0}/_api/web/lists".format(site_url))
options.set_header('Accept', 'application/json')
options.set_header('Content-Type', 'application/json')
data = request.execute_request_direct(options)
s = json.loads(data.content)
μ΄ λ¬Έμ λ PullRequest #168λ‘ μμ λμ΄μΌ ν©λλ€.
μ΄μ λ ꡬ체μ μΈ μ€λ₯ λ©μμ§κ° νμλ©λλ€.
μΈμ¦μ μ€ν¨ν λλ§λ€ μ΄ νΉμ μ€λ₯κ° λ°μνμ΅λλ€.
μ°Έκ³ : μ΅μ λ²μ 2.1.6-1 λ‘ μ κ·Έλ μ΄λν΄μΌ ν©λλ€.
λ§ν¬, @KasperSvendsen λ° @fpinab ,
λΉμ μ΄ μΈκΈ ν μ΄νλ‘ μμ μ λ°μ΄νΈ :
μ¬μ€, λλ AADμ λ΄ μ¬μ©μκ° μμ΅λλ€
ADFSμ© Office 365 Single Sign-On μλ리μ€λ₯Ό μ°Έμ‘°νλ€κ³ μκ°ν©λλ€. μ΄ νλ¦μ μ§μλμ§ μμμΌλ©° μ΄κ²μ΄ μ 곡λ μ€λ₯κ° λ°μν μ΄μ μΌ μ μμ΅λλ€.
μ’μ μμμ SharePoint Onlineμ μ¬μ©ν SAML κΈ°λ° μ°ν© μΈμ¦μ λν μ§μμ΄ 2.1.7
λ²μ μμ λμ
λμλ€λ κ²μ
λλ€.
μ μ 쑰건
μ¬μ©μμ λν λ€λ¨κ³ μΈμ¦ μ΄ λΉνμ±νλ κ²μΌλ‘ κ°μ ν©λλ€.
λ ΈνΈ
μ λ²μ μ΄ μμ§ PyPiμ μΆμ λμ§ μμκΈ° λλ¬Έμ λ€μκ³Ό κ°μ΄ νμ¬ GitHubμμ μ€μΉν΄μΌ ν©λλ€.
ν μ€μΉ git+ https://github.com/vgrem/Office365-REST-Python-Client.git
건배,
λ°λ€
@vgrem
ADFS μλ리μ€λ₯Ό μ§μνκΈ° μν΄ μ λ²μ μΌλ‘ μ
λ°μ΄νΈνμ΅λλ€. νμ§λ§ μ¬μ ν μλνμ§ μμ΅λλ€.
μλλ μ½λ μμ
λλ€.
from office365.runtime.auth.authentication_context import AuthenticationContext
account = "[email protected]"
password = "example"
url = "https://example.sharepoint.com/sites/base-dok-testing"
ctx_auth = AuthenticationContext(url)
ctx_auth.acquire_token_for_user(account, password)
μλλ λ‘κ·Έμ λλ€.
16/Jun/2020 10:18:15] DEBUG [none] [office365.runtime.auth.saml_token_provider.SamlTokenProvider.acquire_token:acquire_token:45] acquire_token called
[16/Jun/2020 10:18:15] DEBUG [none] [office365.runtime.auth.saml_token_provider.SamlTokenProvider.acquire_token:acquire_token:48] Acquiring Access Token..
[16/Jun/2020 10:18:15] DEBUG [none] [urllib3.connectionpool:_new_conn:955] Starting new HTTPS connection (1): login.microsoftonline.com:443
[16/Jun/2020 10:18:16] DEBUG [none] [urllib3.connectionpool:_make_request:428] https://login.microsoftonline.com:443 "POST /GetUserRealm.srf HTTP/1.1" 200 1448
[16/Jun/2020 10:18:16] DEBUG [none] [urllib3.connectionpool:_new_conn:955] Starting new HTTPS connection (1): fs.kerialis.fr:443
[16/Jun/2020 10:18:20] DEBUG [none] [urllib3.connectionpool:_make_request:428] https://fs.kerialis.fr:443 "POST /adfs/services/trust/2005/usernamemixed HTTP/1.1" 200 6542
[16/Jun/2020 10:18:20] DEBUG [none] [urllib3.connectionpool:_new_conn:955] Starting new HTTPS connection (1): login.microsoftonline.com:443
[16/Jun/2020 10:18:21] DEBUG [none] [urllib3.connectionpool:_make_request:428] https://login.microsoftonline.com:443 "POST /rst2.srf HTTP/1.1" 200 3499
[16/Jun/2020 10:18:21] DEBUG [none] [urllib3.connectionpool:_new_conn:955] Starting new HTTPS connection (1): kerialisfr.sharepoint.com:443
[16/Jun/2020 10:18:21] DEBUG [none] [urllib3.connectionpool:_make_request:428] https://kerialisfr.sharepoint.com:443 "HEAD /sites/base-dok-testing/_vti_bin/idcrl.svc HTTP/1.1" 401 0
[16/Jun/2020 10:18:21] ERROR [none] [office365.runtime.auth.saml_token_provider.SamlTokenProvider.acquire_authentication_cookie:acquire_authentication_cookie:208] An error occurred while retrieving auth cookies from https://kerialisfr.sharepoint.com/sites/base-dok-testing/_vti_bin/idcrl.svc
@Simplici , v2.1.8
λλ κ·Έ μ΄ν λ²μ μ΄ κ·νμ νΈμμ νμ©λκ³ μλ€κ³ νμ νμλκΉ?
κ·Έλ μ§ μμΌλ©΄ μ¬κΈ° μ λ³΄κ³ λ κ²κ³Ό λμΌν λ¬Έμ κ° λ°μν μ
@vgrem λλ
μ΅μ λ¦΄λ¦¬μ€ 2.1.9λ‘ μ λ°μ΄νΈν΄λ κ²°κ³Όλ λμΌν©λλ€.
λ΄ λλ£κ° μΌλΆ μμ ν λ€μ μλν©λλ€: https://github.com/vgrem/Office365-REST-Python-Client/issues/210.
@vgrem κ°μ λ¬Έμ κ° μμ΅λλ€. μλ μ½λλ " https://company.sharepoint.com/_vti_bin/idcrl.svc μμ μΈμ¦ μΏ ν€λ₯Ό κ²μνλ λμ μ€λ₯κ° λ°μνμ΅λλ€" μ€λ₯λ₯Ό λ°νν©λλ€.
2.1.7.post1λ μ€μΉνμ§λ§ λ€λ¨κ³ μΈμ¦μ νμΈν κ΄λ¦¬μ μ‘μΈμ€ κΆνμ΄ μμ΅λλ€.
office365.runtime.auth.authentication_contextμμ μΈμ¦ 컨ν
μ€νΈ κ°μ Έμ€κΈ°
office365.sharepoint.client_contextμμ ClientContext κ°μ Έμ€κΈ°
office365.sharepoint.fileμμ νμΌ κ°μ Έμ€κΈ°
URL = ' https://company.sharepoint.com '
μ¬μ©μ μ΄λ¦ = ' [email protected] '
λΉλ°λ²νΈ = 'xxx'
ctx_auth = μΈμ¦ 컨ν μ€νΈ(URL)
ctx_auth.acquire_token_for_user(μ¬μ©μ μ΄λ¦, λΉλ°λ²νΈ)μΈ κ²½μ°:
ctx = ClientContext(URL, ctx_auth)
μΉ = ctx.web
...
κ°μ₯ μ μ©ν λκΈ
μ μκ²λ ν¨κ³Όκ° μμ΅λλ€. URLμ " https://mycompany.sharepoint.com/sites/AnotherSite " λλ " https://mycompany.sharepoint.com/sites/AnotherSite/Subsite "μ κ°μ μλ μμ΅λλ€.
λμ λ€μ μ½λλ‘ μλν΄ λ³΄μΈμ.