Office365-rest-python-client: خطأ في acqu_token_for_user

تم إنشاؤها على ٤ ديسمبر ٢٠١٩  ·  11تعليقات  ·  مصدر: vgrem/Office365-REST-Python-Client

أهلا،

حاولت الاتصال ببوابة Sharepoint على شبكة الإنترانت الخاصة بي باستخدام Office365-REST-Python-Client ، لكنها فشلت عند استدعاء get_token_for_user () من فئة AuthenticationContext:

url = " https://mycompany.sharepoint.com "
ctx_auth = AuthenticationContext (url)
ctx_auth.acquire_token_for_user ("my_username"، "my_password")

يؤدي إلى الخطأ التالي:

AttributeError: الكائن "NoneType" ليس له سمة "text"

يعتبر،
علامة

question

التعليق الأكثر فائدة

إنه يعمل لدي أيضا. يمكن أن يكون عنوان 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)

ال 11 كومينتر

لدي نفس المشكلة بالضبط

نفس الشيء ، ظهر هذا للتو ، لا يمكن الوصول إلى نقطة المشاركة بعد الآن.

لدي نفس المشكلة ولا يمكنني الوصول إلى SharePoint Enterprise. في إصدار آخر (رقم 76 ، في 5 أغسطس 2018) يوضح الحل التالي (الذي لم يعمل معي بعد):

_تم الحل. كانت المشكلة هي استخدام مستخدم الشركة ، والذي يتم إجراء فحص له ، فقط عبر المستعرض ، بين Azure Active Directory و Active Direcotry الداخلي. بالنسبة إلى البرنامج النصي للدفعة ، قمت بإنشاء مستخدم في السحابة AAD._

في الواقع ، لدي مستخدم في AAD ، لكن ما زلت لا أستطيع الوصول: (أي حل / فكرة؟

الكود الخاص بي يعمل:
اسم المستخدم = "اسمي"
passWord = 'mypassword'
ctx_auth.acquire_token_for_user (اسم المستخدم = اسم المستخدم ، كلمة المرور = كلمة المرور)

إنه يعمل لدي أيضا. يمكن أن يكون عنوان 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

أعتقد أنك تشير إلى سيناريو الدخول الموحد لـ

والخبر السار ، أن دعم المصادقة الموحدة المستندة إلى SAML مع SharePoint Online قد تم تقديمه في الإصدار 2.1.7 ، مما يعني المصادقة مع حسابات مستخدمي Active Directory يجب علينا العمل كما هو متوقع الآن.

المتطلبات الأساسية

من المفترض أن المصادقة متعددة العوامل للمستخدم معطلة

ملحوظات

نظرًا لأن الإصدار الجديد لم يتم إصداره إلى PyPi بعد ، فيجب تثبيته من GitHub بدلاً من ذلك في الوقت الحالي ، مثل هذا:

نقطة تثبيت git + https://github.com/vgrem/Office365-REST-Python-Client.git

هتافات،
فاديم

تضمين التغريدة
لقد قمت بالتحديث إلى الإصدار الجديد لمحاولة دعم سيناريو 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.7.post1.

أقوم بالتحديث إلى الإصدار الأخير 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 استيراد AuthenticationContext
من office365.sharepoint.client_context استيراد ClientContext
من office365.sharepoint.file استيراد ملف

url = " https://company.sharepoint.com "
اسم المستخدم = " [email protected] "
كلمة المرور = 'xxx'

ctx_auth = AuthenticationContext (url)

إذا كان ctx_auth.acquire_token_for_user (اسم المستخدم وكلمة المرور):
ctx = ClientContext (عنوان url ، ctx_auth)
الويب = ctx.web
...

هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات