Skip to content

Sharepoint connection with wrong references / error message with client id instead of app id #985

@rfuehrer

Description

@rfuehrer

I receive the following error message when I use the code (at position .execute_query() ) below:

AADSTS700016: Application with identifier 'dddddddd-3dd4-4722-8125-dddddddddddd' was not found in the directory ...

It is apparent that the client ID is being displayed as the application ID in the error message. It seems that the client ID and application ID are not being set correctly in the library. Alternatively, the error message might be misleading, but using the actual application ID, I can find the application via https://portal.azure.com/#home.

What can I do to make the code work?

Based on: https://github.com/vgrem/office365-rest-python-client/blob/master/examples/sharepoint/files/versions/list.py

from office365.azure_env import AzureEnvironment
from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.client_credential import ClientCredential
from office365.runtime.auth.authentication_context import AuthenticationContext

team_site_url = "https://AAAAAA.sharepoint.com/sites/BBBBBB"
app_id = "cccccccc-a42c-4666-a482-cccccccccccc"
client_id = "dddddddd-3dd4-4722-8125-dddddddddddd"
client_secret = "eeeee~hdMX3CyaGMeeeeeeeeomQ6Y8jG5dtP_bAh"

client_credentials = ClientCredential(client_id, client_secret)
file_url = "ffffffff.pdf?csf=1&web=1&e=Lz4U2g"

ctx = ClientContext(team_site_url).with_credentials(client_credentials)

"""
Retrieves versions of the file
"""
file_with_versions = (
    ctx.web.get_file_by_server_relative_path(file_url)
    .expand(["Versions"])
    .get()
    .execute_query()
)

for version in file_with_versions.versions:
    # print(version.properties.get("Created"))
    print(version.version_label)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions