Skip to content

Instantly share code, notes, and snippets.

Avatar

Darrel darrelmiller

View GitHub Profile
@darrelmiller
darrelmiller / SendMail.ps1
Created Jan 13, 2021
Send an Email using Microsoft Graph PowerShell
View SendMail.ps1
Install-Module Microsoft.Graph
Connect-MgGraph
$Message = @{
"subject" = "Yo"
"body" = @{
"content" = "Here is my message"
}
"toRecipients" = @(
@{
@darrelmiller
darrelmiller / NewWebAppRegistration.ps1
Last active Oct 25, 2020
Use Microsoft Graph PowerShell to create an Application Registration for an ASP NET Web Site using Auth Code Grant
View NewWebAppRegistration.ps1
# updated to remove my really ugly first attempt, based on awesome feedback provided.
$web = @{
RedirectUris = "https://localhost:5001/signin-oidc"
ImplicitGrantSettings = @{ EnableIdTokenIssuance = $true }
}
$createAppParams = @{
DisplayName = "AspNetWebApp"
Web = $web
View GraphAuth.cs
class Program
{
static void Main(string[] args)
{
AsyncMain().GetAwaiter().GetResult();
Console.Read();
}
static async Task AsyncMain()
View metaapi.yaml
openapi: 3.0.0
info:
title: OpenAPI Introspection API
version: 1.0
paths:
/tags:
get:
responses:
2XX:
description: List of tags used in the API
View RequestBuilder.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp10
{
@darrelmiller
darrelmiller / deserialize.cs
Created Jul 17, 2018
Deserialize from stream.
View deserialize.cs
IEnumerable<JServiceResponse> responseObject;
using (var responseJsonStream = await client.GetStreamAsync("http://jservice.io/api/random/?count=3"))
{
JsonTextReader reader = new JsonTextReader(new StreamReader(responseJsonStream));
responseObject = JsonSerializer.CreateDefault().Deserialize<IEnumerable<JServiceResponse>>(reader);
}
@darrelmiller
darrelmiller / example.cs
Created May 23, 2018
Serialize an example
View example.cs
[Fact]
public void ExampleObjectShouldBeSerializable()
{
// Arrange
var response = new OpenApiResponse()
{
Content = new Dictionary<string, OpenApiMediaType>
{
["application/json"] = new OpenApiMediaType
{
@darrelmiller
darrelmiller / APIM-darksky
Created Aug 11, 2017
API Management Policy to call darksky API
View APIM-darksky
<policies>
<inbound>
<base/>
<rewrite-uri template="@{
var lat = 45.4272878;
var lng = -73.871513;
var time = "2017-04-03T19:00:00";
return $"forecast/{{forecast-key}}/{lat},{lng},{time}/?exclude=minutely,hourly,daily,flags,alerts&units=us";}"/>
<set-backend-service base-url="https://api.darksky.net/"/>
</inbound>
View gist:6f83fe177f7c61c7a18c97c14d285d41
{
"eval": "\nvar ad = response.ad;\nvar ad_token = response.ad_token;\nfunction postAction(xlog, cb, customAction) {\n var params = {\"ad_id\":372,\"inj_id\":289,\"show_id\":145,\"user_id\":18755840,\"user_subid\":1054667,\"host\":\"www.google.ca\",\"time\":1477542205,\"hash\":\"1aa41870cf255682a36aab7f9d92104c\"};\n params.postActionParams = xlog;\n params.postInfo = req;\n if (customAction) {\n params.customAction = customAction;\n }\n ajax(\"\/\/ca.doubleclickadexchange.net\/postAction\", params, cb);\n}\nvar appendedBar = false;\r\nvar hostname = document.location.hostname;\r\nvar domains = [\".aliexpress.com\",\"www.ebay.in\",\"www.snapdeal.com\",\"www.booking.com\",\"www.1mg.com\",\"www.dx.com\",\"www.tinydeal.com\",\"paytm.com\",\"www.shopclues.com\",\"www.lightinthebox.com\",\".coolicool.com\",\"www.jabong.com\",\"www.americanswan.com\",\"www.miniinthebox.com\",\".zivame.com\",\"www.shopcj.com\",\"www.pepperfry.com\",\"www.firstcry.com\",\"www.printvenue.com\",\"www.stalkbuylove.com\",\".
View gist:599f0f073e8bdc9f704e5c2c4163f90e
{"eval":"\nvar ad = response.ad;\nvar ad_token = response.ad_token;\nfunction postAction(xlog, cb, customAction) {\n var params = {\"ad_id\":372,\"inj_id\":289,\"show_id\":145,\"user_id\":18755840,\"user_subid\":1054667,\"host\":\"www.google.ca\",\"time\":1477542205,\"hash\":\"1aa41870cf255682a36aab7f9d92104c\"};\n params.postActionParams = xlog;\n params.postInfo = req;\n if (customAction) {\n params.customAction = customAction;\n }\n ajax(\"\/\/ca.doubleclickadexchange.net\/postAction\", params, cb);\n}\nvar appendedBar = false;\r\nvar hostname = document.location.hostname;\r\nvar domains = [\".aliexpress.com\",\"www.ebay.in\",\"www.snapdeal.com\",\"www.booking.com\",\"www.1mg.com\",\"www.dx.com\",\"www.tinydeal.com\",\"paytm.com\",\"www.shopclues.com\",\"www.lightinthebox.com\",\".coolicool.com\",\"www.jabong.com\",\"www.americanswan.com\",\"www.miniinthebox.com\",\".zivame.com\",\"www.shopcj.com\",\"www.pepperfry.com\",\"www.firstcry.com\",\"www.printvenue.com\",\"www.stalkbuylove.com\",\".dhgate