コード例 #1
0
        public GoogleAccessTokenResponse GetAccessTokenFromRefreshToken(string refreshToken)
        {
            // Declare the POST data
            NameValueCollection postData = new NameValueCollection {
                { "client_id", ClientIdFull },
                { "client_secret", ClientSecret },
                { "refresh_token", refreshToken },
                { "grant_type", "refresh_token" }
            };

            // Make a call to the server
            JsonObject json = SocialUtils.DoHttpPostRequestAndGetBodyAsJsonObject("https://accounts.google.com/o/oauth2/token", null, postData);

            // Check for an error message
            if (json.HasValue("error"))
            {
                throw new Exception(json.GetString("error"));
            }

            // Parse the JSON response
            return(GoogleAccessTokenResponse.Parse(json));
        }