Skip to content

Instantly share code, notes, and snippets.

@rupertbenbrook
rupertbenbrook / policy.xml
Last active March 3, 2026 08:13
Azure API Management inbound policy for backend OAuth2 client credentials flow with token caching
<!--
This relies on a number of properties being defined in API Management:
• EnableCache – Either “true” or “false”. This is used to enable and disable caching of tokens.
• OAuth2TokenEndpoint – The AAD OAuth2 token endpoint URI to get a token from. It takes the form https://login.microsoftonline.com/<subscription-guid>/oauth2/token.
• OAuth2ClientCredentials – The client ID GUID of the AAD application registered for the API Management server to authenticate.
• OAuth2ClientSecret – The client secret key generated for the AAD application registered for the API Management server.
• OAuth2Resource – The application ID URI for the application whose API is being accessed, and who is enabled for delegation in the AAD application registered for the API Management server.
-->
@bitwalker
bitwalker / Option.cs
Created July 11, 2014 20:32
Implementation of Option<T> in C#
using System;
namespace Types
{
public static class Option
{
public static Option<T> ToOption<T>(this T @this)
{
if (@this == null)
return Option<T>.None;