Esempio n. 1
0
        public OauthWebAuthHelper(OauthConfiguration configuration, Version version = Version.V1)
        {
            _configuration = configuration;

            switch (version)
            {
            case Version.V1: _authorizeSuffix = OAUTH2_AUTHORIZE_V1_SUFFIX; break;

            case Version.V2: _authorizeSuffix = OAUTH2_AUTHORIZE_V2_SUFFIX; break;
            }
        }
        public void Run()
        {
            var oauth = new OauthConfiguration
            {
                Authority   = "https://login.microsoftonline.com",
                Tenant      = "common",
                ClientId    = "f6eddbd9-e3bb-4610-9ebb-0fc31291ab1e",
                RedirectURI = "urn:ietf:wg:oauth:2.0:oob"
            };

            var helper = new OauthWebAuthHelper(oauth, OauthWebAuthHelper.Version.V2);

            var token = helper.AcquireTokenWithScope("Files.Read");
        }
Esempio n. 3
0
        public void Run()
        {
            var oauth = new OauthConfiguration
            {
                Authority   = "https://login.microsoftonline.com",
                Tenant      = "common",
                ClientId    = "24bb1725-54d9-4190-b58c-ba5347fb336e",
                RedirectURI = "http://localhost"
            };

            var flow = new AuthorizationCodeGrantFlow();

            flow.Go(oauth);
        }
Esempio n. 4
0
        public void Go(OauthConfiguration oauth)
        {
            var auth = new OauthWebAuthHelper(oauth);

            var tokenResponse = auth.AcquireTokenWithResource(resource: "https://outlook.office.com");

            Console.WriteLine("access token:");

            Console.WriteLine(tokenResponse);

            var accessToken = tokenResponse.GetValue("access_token").Value <string>();

            var validator = new JsonWebTokenValidator();

            var jwt = validator.Validate(accessToken);

            Console.WriteLine(JsonConvert.SerializeObject(jwt.Payload, Formatting.Indented));

            Console.ReadLine();
        }