Ejemplo n.º 1
0
        public async Task<string> Connect(IOAuth authenticator, string GeneralRedirectUrl)
        {
            SetUp("https://getpocket.com/v3/");
            if (Pocket_access_token != null)
            {
                AddStandardParameter(new Param("access_token", Pocket_access_token));
                AddStandardParameter(new Param("consumer_key", PocketKey));
                return Pocket_access_token;
            }

            List<Param> parameters = new List<Param>
            {
                new Param("consumer_key", PocketKey),
                new Param("redirect_uri", "zeus://")
            };

            IRestResponse resp = await HandleRequest("oauth/request.php", Call.POST, parameters: parameters);
            
            string code = resp.Content.Replace("code=", "");

            authenticator.ActivateOAuth(new Uri("https://getpocket.com/auth/authorize?request_token=" + code + "&redirect_uri=" + GeneralRedirectUrl));

            parameters = new List<Param>
            {
                new Param("consumer_key", PocketKey),
                new Param("code", code)
            };

            resp = await HandleRequest("oauth/authorize.php", Call.POST, parameters: parameters);

            var noAccessToken = resp.Content.Replace("access_token=", "");
            string accessToken = noAccessToken.Remove(30, resp.Content.Length - 13 - 30);

            return accessToken;
        }
Ejemplo n.º 2
0
        public async Task<string> Connect(IOAuth _authenticator)
        {
            SetUp("https://www.wunderlist.com/oauth/access_token");
            if (WunderlistToken == null)
            {

                string url = "https://www.wunderlist.com/oauth/authorize?client_id=" + WunderlistId + "&redirect_uri=" + "https://developer.wunderlist.com" + "&state=PleasCopyThis";
                string res = _authenticator.ActivateOAuth(new Uri(url), "https://developer.wunderlist.com");
                string token = Regex.Match(res, "code=(.+)").Groups[1].Value;

                Auth auth = await MakeRequest<Auth>("", Call.POST, new List<Param>
                {
                    new Param("client_id", WunderlistId),
                    new Param("code", token),
                    new Param("client_secret", WunderlistSecret)
                });

                WunderlistToken = auth.access_token;
            }

            SetBaseUrl("https://a.wunderlist.com/api/v1/");

            AddStandardHeader(new Param("X-Access-Token", WunderlistToken));
            AddStandardHeader(new Param("X-Client-ID", WunderlistId));

            return WunderlistToken;
        }
Ejemplo n.º 3
0
        public async Task Connect(string outlookId, string redirectUrl, IOAuth authe)
        {
            var uri =
                new Uri("https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=" + outlookId +
                        "&redirect_uri=" + redirectUrl +
                        "&response_type=code&scope=https%3A%2F%2Foutlook.office.com%2FMail.ReadWrite+https%3A%2F%2Foutlook.office.com%2FCalendars.ReadWrite+" +
                        "offline_access");
            string return_url = authe.ActivateOAuth(uri);
            

            string login_code = return_url.Replace("code=","");

            SetBaseUrl("https://outlook.office.com/api/v1.0/");
        }
Ejemplo n.º 4
0
 public void Connect(IOAuth _authenticator)
 {
     var url = "https://github.com/login/oauth/authorize?redirect_uri=" + _authenticator.RedirectUrl() + "&client_id=" + GitHub_clientID + "&scope=repo,notifications,admin:org";
     _authenticator.ActivateOAuth(new Uri(url));
 }