private void ObtainAccessTokenResponseAndRaiseOpenEvent(string authenticationCode) { var accessTokenUrl = BuildAccessTokenUri(); var webClient = new WebClient(); webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; string data = string.Format("code={0}&client_id={1}&client_secret={2}&redirect_uri={3}&grant_type=authorization_code", authenticationCode, _clientId, _clientSecret, _redirectUri); webClient.UploadStringCompleted += (o, e) => { _accessTokenResponse = JsonSerializer.DeserializeFromString<AccessTokenResponse>(e.Result); _managementApi = new ManagementApi(this); if (ConnectionOpened != null) { ConnectionOpened(this, new ConnectionOpenedEventArgs { Response = _accessTokenResponse }); } }; webClient.UploadStringAsync(accessTokenUrl, data); }