public static void DoSomeOauth2()
        {
            var request_factory = new OAuth2.Infrastructure.RequestFactory();

            request_factory.CreateRequest();
            request_factory.CreateClient();



            var config = new OAuth2.Configuration.RuntimeClientConfiguration();

            config.ClientId     = CLIENT_ID;
            config.ClientSecret = CLIENT_SECRET;
            config.RedirectUri  = REDIRECT.ToString();



            var oauthin = new OAuth2.Client.Impl.GoogleClient(request_factory, config);

            oauthin.GetCurrentToken();



            service        = new RequestService(HANDLER);
            Program.config = new CanvasConfig(DOMAIN, CLIENT_ID, CLIENT_SECRET, REDIRECT);

            var request = new ApiRequest(new Uri("https://instantadmin.instructure.com/login/oauth2/auth"))
                          .Param("client_id", CLIENT_ID)
                          .Param("response_type", "code")
                          .Param("redirect_uri", REDIRECT.ToString())
            ;

            //var basic = await HANDLER.ExecuteAsync<OAuth2Session>(request).ConfigureAwait(false);

            //session = new OAuth2Session(access_token, refresh_token, expires_in, token_type);
            auth = new AuthRepository(Program.config, service, CONVERTER);

            client = new Client(Program.config, auth);

            //var courses = await client.CoursesManager.GetAll();

            //foreach(var course in courses)
            //{
            //    Console.WriteLine(course.ToString());
            //}


            //return;
        }
예제 #2
0
        public Twitter()
        {
            var secrets = SecretsClient.Get("twitter");

            var config = new RuntimeClientConfiguration()
            {
                ClientId = secrets.Key,
                ClientSecret = secrets.Secret
            };

            client = new TwitterClient(new RequestFactory(), config);

            AccessToken = Configuration.TwitterToken;
            accessTokenSecret = Configuration.TwitterTokenSecret;
        }
예제 #3
0
        public Google()
        {
            var secrets = SecretsClient.Get("google");

            var config = new RuntimeClientConfiguration()
            {
                ClientId = secrets.Key,
                ClientSecret = secrets.Secret,
                Scope = @"https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email",
                RedirectUri = "urn:ietf:wg:oauth:2.0:oob"
            };

            client = new GoogleClient(new RequestFactory(), config);

            AccessToken = Configuration.GoogleRefreshToken;
        }