public static XingNetTokenHandler _TokenHandler;
   static string ConsumerKey = "<AddYourKey>";
   static string ConsumerSecret = "<AddYourKey>";
   static Uri CallbackUrl;

    public ActionResult Login()
      //Create the TokenHandler
      _TokenHandler = new XingNetTokenHandler(ConsumerKey, ConsumerSecret);
      //Set your CallbackURL
      CallbackUrl = new Uri(Request.Url.Scheme + "://" + 
                                      Request.Url.Authority + "/Home/LoginCallBack");

      //Step 1 : Get Authorization Token
      var client = XingBaseClient.GetAuthorizationClient(_TokenHandler, CallbackUrl);
      var request = new RestRequest("v1/request_token", Method.POST);
      var response = client.Execute(request);

      //Step 2 : Use Token to get the verifier.
     // This step needs the user to accept your application
     // So we need to redirect the user to the Authorization Page
      var qs = HttpUtility.ParseQueryString(response.Content);
      _TokenHandler.Access_Token = qs["oauth_token"];
      _TokenHandler.Access_Token_Secret = qs["oauth_token_secret"];

      request = new RestRequest("/v1/authorize");
      request.AddParameter("oauth_token", _TokenHandler.Access_Token);
      var url = client.BuildUri(request).ToString();

  // Step 3, After the user accepted the call , he get´s redirected to our "callback url" 
    public ActionResult LoginCallBack()
      // Use Access Token and Verifier to get the last Token needed
      _TokenHandler.Access_Token = Request["oauth_token"];
      _TokenHandler.Verifier = Request["oauth_verifier"];
      var request = new RestRequest("/v1/access_token", Method.POST);
      var client = XingBaseClient.GetClient(_TokenHandler, 
      var response = client.Execute(request);

      //Change tokens to the correct Access Tokens
     // now we have all Tokens in our TokenManager
      var qs = HttpUtility.ParseQueryString(response.Content);
      _TokenHandler.Access_Token = qs["oauth_token"];
      _TokenHandler.Access_Token_Secret = qs["oauth_token_secret"];
      //Now we can use the API
      return RedirectToAction("About","Home");

    public ActionResult About()
      //Create ProfileHandler to catch data. 
      UserProfileHandler Handler = new UserProfileHandler(_TokenHandler);
      UserResponse user = Handler.GetProfileForLoggedInUser();
      return View(user.UserProfiles[0]);

Last edited Feb 10, 2013 at 4:10 PM by DeeJayTC, version 3


DeeJayTC Aug 12, 2013 at 7:42 PM 
We merged all calls into one...simply use XingBaseClient.GetClient(xx) sorry for late answer

MaxHorstmann May 1, 2013 at 2:54 PM 
Is there an updated version of this example? XingBaseClient.GetAuthorizationClient doesn't seem to exit anymore, for instance.