View index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { config } from 'dotenv'; | |
import * as path from 'path'; | |
import "isomorphic-fetch"; | |
import { Client, ClientOptions } from "@microsoft/microsoft-graph-client"; | |
import { ClientCredentialAuthenticationProvider } from "./AuthenticationProvider" | |
// Read environment variables from .env file | |
const ENV_FILE = path.join(__dirname, '.env'); | |
config({ path: ENV_FILE }); |
View AuthenticationProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AuthenticationProvider } from "@microsoft/microsoft-graph-client"; | |
import * as qs from "qs"; | |
import axios from "axios" | |
export class ClientCredentialAuthenticationProvider implements AuthenticationProvider { | |
public async getAccessToken(): Promise<string> { | |
const url: string = "https://login.microsoftonline.com/" + process.env.MicrosoftAppTenantId + "/oauth2/v2.0/token"; |
View TeamsNetworkUsageWorkbook.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "Notebook/1.0", | |
"items": [ | |
{ | |
"type": 1, | |
"content": { | |
"json": "## Teams Client Network Usage\n" | |
}, | |
"name": "text - 2" | |
}, |
View TeamsAdaptiveCardTweet.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json", | |
"type": "AdaptiveCard", | |
"version": "1.2", | |
"body": [ | |
{ | |
"type": "TextBlock", | |
"text": "@{triggerBody()?['UserDetails']?['FullName']} has mentioned you on Twitter", | |
"weight": "Bolder", | |
"size": "Large" |
View SampleAdaptiveCard.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json", | |
"type": "AdaptiveCard", | |
"version": "1.2", | |
"body": [ | |
{ | |
"type": "TextBlock", | |
"text": "Publish Adaptive Card schema", | |
"weight": "bolder", | |
"size": "large" |
View GraphAPIDeviceCode.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Application (client) ID, tenant ID, resource and scope | |
$clientId = "" | |
$tenantId = "" | |
$resource = "https://graph.microsoft.com/" | |
$scope = "Group.Read.All" | |
$codeBody = @{ | |
resource = $resource | |
client_id = $clientId |
View Get-ChannelWebpageTabs.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get-ChannelWebpageTabs.ps1 | |
# Example script to list all webpage Tabs in Teams Channels | |
function GraphAPICall { | |
param ( | |
[Parameter(mandatory = $true)][uri]$URI | |
) | |
$Headers = @{"Authorization" = "Bearer $script:token" } |
View GraphAPIPaging.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GraphAPIPaging.ps1 | |
# Example script on paging with Graph API | |
### Authenticate ### | |
# Application (client) ID, tenant ID and secret | |
$clientId = "" | |
$tenantId = "" | |
$clientSecret = '' | |
# Construct URI |
View New-Team.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# New-Team.ps1 | |
# Create a new Team using Graph API | |
# Application (client) ID, tenant ID and secret | |
$clientId = "clientid" | |
$tenantId = "tenantid" | |
$clientSecret = 'secret' | |
# Contruct URI | |
$uri = "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token" |
View Get-Me.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get-Me.ps1 | |
# Get logged in user using Graph API | |
# Add required assemblies | |
Add-Type -AssemblyName System.Web, PresentationFramework, PresentationCore | |
# Application (client) ID, tenant ID and redirect URI | |
$clientId = "clientid" | |
$tenantId = "tenantid" | |
$redirectUri = "https://login.microsoftonline.com/common/oauth2/nativeclient" |
NewerOlder