public byte[] Decode(string text)
 {
     if (text == null)
     {
         throw new ArgumentNullException("text");
     }
     return(Convert.FromBase64String(Base64UrlTextEncoder.Pad(text.Replace('-', '+').Replace('\u005F', '/'))));
 }
        // IIS will use ASP.NET machine key data protection
        // HttpListener and other self - hosted servers will use DPAPI data protection
        public static SecureDataFormat <AuthenticationTicket> Create()
        {
            string[] purposes = new string[] { typeof(OAuthBearerAuthenticationMiddleware).Namespace, "Access_Token", "v1" };
            var      dp       = new MachineKeyDataProtector(purposes);
            var      enc      = new Base64UrlTextEncoder();
            var      ts       = new TicketSerializer();
            var      sdf      = new SecureDataFormat <AuthenticationTicket>(ts, dp, enc);

            return(sdf);
        }