Exemple #1
0
        public bool ValidateReturnValue(string returnValue)
        {
            // 6. Exchange auth.token for access.token
            Uri uri = new Uri("http://data.hyves-api.nl/?ha_method=auth.accesstoken&ha_version=experimental&ha_format=xml&ha_fancylayout=false");

            XElement accessResult = HyvesApiRequest.PerformRequest(uri, Token, TokenSecret);

            if (ChannelContext.Current == null)
            {
                throw new ArgumentNullException("ChannelContext.Current");
            }

            string authorizedToken  = accessResult.Element("oauth_token").Value;
            string authorizedSecret = accessResult.Element("oauth_token_secret").Value;
            string userid           = accessResult.Element("userid").Value;

            // Remove token from session
            SafeSession.Current.Remove("/Channels/Hyves/Redirect/Token");
            SafeSession.Current.Remove("/Channels/Hyves/Redirect/TokenSecret");

            // 7. Save auth keys
            ChannelContext.Current.ClientContext.SaveSetting("/Channels/Hyves/AuthToken", authorizedToken);
            ChannelContext.Current.ClientContext.SaveSetting("/Channels/Hyves/AuthSecret", authorizedSecret);
            ChannelContext.Current.ClientContext.SaveSetting("/Channels/Hyves/UserId", userid);

            return(true);
        }
        internal static XElement PerformRequest(string requestUri)
        {
            var authorizedToken  = ChannelContext.Current.ClientContext.GetSetting("/Channels/Hyves/AuthToken").ToString();
            var authorizedSecret = ChannelContext.Current.ClientContext.GetSetting("/Channels/Hyves/AuthSecret").ToString();

            return(HyvesApiRequest.PerformRequest(new Uri(requestUri), authorizedToken, authorizedSecret));
        }
Exemple #3
0
        public Uri BuildRedirectUri()
        {
            // 1. Get Auth Token
            Uri uri = new Uri(String.Format("http://data.hyves-api.nl/?methods={0}&expirationtype=infinite&ha_method=auth.requesttoken&ha_version=experimental&ha_format=xml&ha_fancylayout=false", HyvesApiRequest.AllMethods));

            XElement result = HyvesApiRequest.PerformRequest(uri);

            Token       = result.Element("oauth_token").Value;
            TokenSecret = result.Element("oauth_token_secret").Value;

            // Save data in session for re-materialization
            SafeSession.Current["/Channels/Hyves/Redirect/Token"]       = Token;
            SafeSession.Current["/Channels/Hyves/Redirect/TokenSecret"] = TokenSecret;

            return(new Uri(String.Format("http://www.hyves.nl/api/authorize/?oauth_token={0}&oauth_callback={1}", Token, BuildEnvironmentUrl())));
        }