void RenewAccessToken(string packageSecurityIdentifier, string clientSecret) { var postData = new StringBuilder(); postData.AppendFormat("{0}={1}&", "grant_type", "client_credentials"); postData.AppendFormat("{0}={1}&", "client_id", HttpUtility.UrlEncode(packageSecurityIdentifier)); postData.AppendFormat("{0}={1}&", "client_secret", HttpUtility.UrlEncode(clientSecret)); postData.AppendFormat("{0}={1}", "scope", "notify.windows.com"); var wc = new WebClient(); wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); var response = string.Empty; response = wc.UploadString("https://login.live.com/accesstoken.srf", postData.ToString()); OAuthToken oauthTok = OAuthToken.GetOAuthTokenFromJson(response); if (oauthTok != null) { this.AccessToken = oauthTok.AccessToken; this.TokenType = oauthTok.TokenType; } else { throw new UnauthorizedAccessException("Could not retrieve access token for the supplied Package Security Identifier (SID) and client secret"); } }