CartoDBClient.oAuthCartoDB.xAuthAccessTokenGet C# (CSharp) Метод

xAuthAccessTokenGet() публичный Метод

Exchange the username and password for an access token.
public xAuthAccessTokenGet ( ) : void
Результат void
        public void xAuthAccessTokenGet()
        {
            this.xAuthUsername = Properties.Settings.Default.mail;
            this.xAuthPassword = Properties.Settings.Default.pass;

            string response = oAuthWebRequest(Method.GET, XAUTH_ACCESS_TOKEN, String.Empty);

            if (response.Length > 0)
            {
                //Store the Token and Token Secret
                NameValueCollection qs = HttpUtility.ParseQueryString(response);
                if (qs["oauth_token"] != null)
                {
                    this.Token = qs["oauth_token"];
                }
                if (qs["oauth_token_secret"] != null)
                {
                    this.TokenSecret = qs["oauth_token_secret"];
                }
            }
        }

Usage Example

        static void Main(string[] args)
        {
            // Update property settings in Properties/Settings.settings at CartoDBClient Project
            // with access values gived by  CartoDB

            // mail: username to access CartoDB
            // pass: password to access CartoDB
            // consumerKey: consumer key in "Your api keys"
            // consumerSecret: consumer secret in "Your api keys"
            // domain: your subdomain in  cartodb.com: http://yoursubdomain.cartodb.com

            // Create the client using xAuth protocol.
            // Update property settings in Properties/Settings.settings at CartoDBClient Project

            oAuthCartoDB oAuth = new oAuthCartoDB();
            oAuth.xAuthAccessTokenGet();

            // Now we can perform queries straigh away.
            // The result return the raw json string
            string jsonString = oAuth.oAuthCartoDBQuery("select * from table");
        }