async private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(AccessToken)) { OrganizationsList.Visibility = Visibility.Collapsed; AuthBrowser.Visibility = Visibility.Visible; var url = Common.FormatAuthUrl( AuthorizationEndpointUrl, ResponseTypes.Code, ConsumerKey, CallbackUrl, DisplayTypes.Touch); AuthBrowser.Navigate(new Uri(url)); return; } var auth = new AuthenticationClient(); await auth.WebServer(ConsumerKey, ConsumerSecret, CallbackUrl, AccessToken); var client = new ForceClient(auth.InstanceUrl, auth.AccessToken, auth.ApiVersion); var accounts = await client.Query<Account>("SELECT id, name, description FROM Account"); OrganizationsList.Visibility = Visibility.Visible; AuthBrowser.Visibility = Visibility.Collapsed; OrganizationsList.ItemsSource = accounts; }
public async Task<HttpResponseMessage> Get(string display, string code) { var auth = new AuthenticationClient(); await auth.WebServer(_consumerKey, _consumerSecret, _callbackUrl, code); var url = string.Format("/?token={0}&api={1}&instance_url={2}", auth.AccessToken, auth.ApiVersion, auth.InstanceUrl); var response = new HttpResponseMessage(HttpStatusCode.Redirect); response.Headers.Location = new Uri(url, UriKind.Relative); return response; }