{"id":19750441,"url":"https://github.com/andrefelipebarros/msgraph-api-sample","last_synced_at":"2025-06-20T03:04:32.853Z","repository":{"id":246425730,"uuid":"821091086","full_name":"andrefelipebarros/msgraph-api-sample","owner":"andrefelipebarros","description":"Este repositório contém um exemplo de integração com a Microsoft Graph API usando Python. Ele demonstra como autenticar e fazer chamadas à API utilizando requests e azure.identity.InteractiveBrowserCredential.","archived":false,"fork":false,"pushed_at":"2024-06-27T20:01:49.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T08:31:18.032Z","etag":null,"topics":["api-rest","msgraph","msgraphapi","python","requests-library-python"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrefelipebarros.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-27T19:47:08.000Z","updated_at":"2024-09-30T01:33:00.000Z","dependencies_parsed_at":"2024-06-27T23:22:58.764Z","dependency_job_id":null,"html_url":"https://github.com/andrefelipebarros/msgraph-api-sample","commit_stats":null,"previous_names":["andrefelipebarros/msgraph-api-sample"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andrefelipebarros/msgraph-api-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrefelipebarros%2Fmsgraph-api-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrefelipebarros%2Fmsgraph-api-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrefelipebarros%2Fmsgraph-api-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrefelipebarros%2Fmsgraph-api-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrefelipebarros","download_url":"https://codeload.github.com/andrefelipebarros/msgraph-api-sample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrefelipebarros%2Fmsgraph-api-sample/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260868841,"owners_count":23074958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-rest","msgraph","msgraphapi","python","requests-library-python"],"created_at":"2024-11-12T02:34:45.944Z","updated_at":"2025-06-20T03:04:27.841Z","avatar_url":"https://github.com/andrefelipebarros.png","language":null,"readme":"# Utilizando a Microsoft Graph API\n\nEste projeto demonstra como utilizar a Microsoft Graph API para acessar dados do Microsoft 365. O script utiliza a biblioteca `requests` para fazer chamadas HTTP e `azure.identity.InteractiveBrowserCredential` para autenticação.\n\n## Pré-requisitos\n\n- Python 3.6 \u003c 3.x\n- Uma conta Microsoft 365\n\n## Instalação\n\n1. Clone este repositório:\n\n```bash\ngit clone https://github.com/seu-usuario/seu-repositorio.git\ncd seu-repositorio\n```\n\n2. Crie e ative um ambiente virtual:\n\n```bash\npython -m venv venv\nsource venv/bin/activate  #No Windows, use `venv\\Scripts\\activate`\n```\n\n3. Instale as dependências:\n\n```bash\npip install -r requirements.txt\n```\n\n## Como Utilizar:\n\n### Importações Necessárias\n\n```python\nimport requests\nfrom azure.identity import InteractiveBrowserCredential\n```\n\n### Funções Utilitárias\n\n```python\n# Obter token de acesso usando azure-identity\ndef get_access_token():\n    credentials = InteractiveBrowserCredential()\n    token = credentials.get_token(\"https://graph.microsoft.com/.default\")\n    return token.token\n\n# Obter o ID do site\ndef get_site_id(access_token):\n    url = 'https://graph.microsoft.com/v1.0/sites/root'\n    headers = {\n        'Authorization': f'Bearer {access_token}',\n        'Content-Type': 'application/json'\n    }\n    response = requests.get(url, headers=headers)\n    if response.status_code == 200:\n        return response.json()['id']\n    else:\n        print(f\"Erro ao obter site ID: {response.status_code}\")\n        return None\n\n# Função principal\ndef main():\n    access_token = get_access_token()\n    site_id = get_site_id(access_token)\n    \n    if site_id:\n        print(\"Site ID:\", site_id)\n    else:\n        print(\"Erro ao obter site ID\")\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Executando o Script\n\nPara executar o script:\n\n```bash\npython seu_script.py\n```\n\nEste script realiza a autenticação usando `azure.identity` e obtém o ID do site raiz do Microsoft 365. Certifique-se de estar autenticado e ter as permissões necessárias para acessar a Graph API antes de executar o script.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrefelipebarros%2Fmsgraph-api-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrefelipebarros%2Fmsgraph-api-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrefelipebarros%2Fmsgraph-api-sample/lists"}