8000 Adding example for Microsoft Intune by fivetran-kirkvanarkel · Pull Request #107 · fivetran/fivetran_connector_sdk · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adding example for Microsoft Intune #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

fivetran-kirkvanarkel
Copy link
Collaborator

No description provided.

Copy link
height bot commented Apr 7, 2025

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@orizwanft orizwanft requested a review from varundhall May 9, 2025 14:38
@orizwanft orizwanft self-assigned this May 9, 2025
@fivetran-elijahdavis fivetran-elijahdavis self-assigned this May 9, 2025
Comment on lines +39 to +48

The `requirements.txt` file specifies any additional Python libraries required by the connector. For this example, the following libraries are required:

*Example content of `requirements.txt`:*

```
requests
```

Note: The `fivetran_connector_sdk:latest` and `requests:latest` packages are pre-installed in the Fivetran environment. To avoid dependency conflicts, do not declare them in your `requirements.txt`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is confusing, we should mention no requirements are needed for this example

Comment on lines +2 to +4
"tenant_id": "<your_tenant_id>",
"client_id": "<your_client_id>",
"client_secret": "<your_client_secret>"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change them to UPPER_CASE

import json

# Define base URL for Microsoft graph API
base_url = "https://graph.microsoft.com/v1.0/"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use UPPER_CASE for constants

Suggested change
base_url = "https://graph.microsoft.com/v1.0/"
BASE_URL = "https://graph.microsoft.com/v1.0/"

8000

Comment on lines +44 to +49
if response.status_code == 200:
access_token = response.json().get("access_token")
else:
log.severe(f"Error: {response.status_code} - {response.text}")

return access_token
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be something like

    if response.status_code == 200:
        access_token = response.json().get("access_token")
        return access_token
    else:
        log.severe(f"Error: {response.status_code} - {response.text}")
        raise RuntimeError("Unable to fetch access_token")

auth_url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token"
headers = {"Content-Type": "application/x-www-form-urlencoded"}
payload = f'grant_type=client_credentials&client_id={client_id}&client_secret={client_secret}&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default'
response = requests.post(auth_url, headers=headers, data=payload)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no retry?

while more_devices:

# Call API and retrieve JSON response
print(f"Calling API: {devices_url}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use proper logging method, if needed


# Call API and retrieve JSON response
print(f"Calling API: {devices_url}")
response = requests.get(devices_url, headers=headers)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No retry? Generally APIs can fail intermittenly sometimes, retries ensure the code works properly in such intermittent cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0