public void Home()
        {
            ILinkedIn linkedInClient = this.LinkedInServiceProvider.GetApi(this.OAuthToken.Value, this.OAuthToken.Secret);

            linkedInClient.ProfileOperations.GetUserProfileAsync(
                r =>
            {
                this.Profile = r.Response;
            });
        }
Example #2
0
        static void Main(string[] args)
        {
            try
            {
                LinkedInServiceProvider linkedInServiceProvider = new LinkedInServiceProvider(LinkedInApiKey, LinkedInApiSecret);


                /* OAuth 'dance' */

                // Authentication using Out-of-band/PIN Code Authentication
                System.Console.Write("Getting request token...");
                NameValueCollection parameters = new NameValueCollection();

                parameters.Add("scope", "r_basicprofile r_emailaddress");
                OAuthToken oauthToken = linkedInServiceProvider.OAuthOperations.FetchRequestTokenAsync("oob", parameters).Result;

                System.Console.WriteLine("Done");

                string authenticateUrl = linkedInServiceProvider.OAuthOperations.BuildAuthorizeUrl(oauthToken.Value, null);
                System.Console.WriteLine("Redirect user for authentication: " + authenticateUrl);
                Process.Start(authenticateUrl);
                System.Console.WriteLine("Enter PIN Code from LinkedIn authorization page:");
                string pinCode = System.Console.ReadLine();

                System.Console.Write("Getting access token...");
                AuthorizedRequestToken requestToken     = new AuthorizedRequestToken(oauthToken, pinCode);
                OAuthToken             oauthAccessToken = linkedInServiceProvider.OAuthOperations.ExchangeForAccessTokenAsync(requestToken, null).Result;
                System.Console.WriteLine("Done");

                /* API */

                ILinkedIn linkedIn = linkedInServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

                LinkedInProfile profile = linkedIn.ProfileOperations.GetUserProfileAsync().Result;

                string    stringResult = linkedIn.RestOperations.GetForObject <string>("skill?name=java&format=json");
                JsonValue jsonResult   = linkedIn.RestOperations.GetForObject <JsonValue>("skill?name=java&format=json");
            }
            catch (AggregateException ae)
            {
                System.Console.WriteLine(ae.GetBaseException());
            }



            catch (Exception ex)
            {
                System.Console.WriteLine(ex);
            }
            finally
            {
                System.Console.WriteLine("--- hit <return> to quit ---");
                System.Console.ReadLine();
            }
        }
Example #3
0
        // GET: /LinkedIn/Callback
        public ActionResult Callback(string oauth_verifier)
        {
            OAuthToken             requestToken           = Session["RequestToken"] as OAuthToken;
            AuthorizedRequestToken authorizedRequestToken = new AuthorizedRequestToken(requestToken, oauth_verifier);
            OAuthToken             token = linkedInProvider.OAuthOperations.ExchangeForAccessTokenAsync(authorizedRequestToken, null).Result;

            Session["AccessToken"] = token;

            ILinkedIn       linkedInClient = linkedInProvider.GetApi(token.Value, token.Secret);
            LinkedInProfile profile        = linkedInClient.ProfileOperations.GetUserProfileAsync().Result;

            return(View(profile));
        }
        static void Main(string[] args)
        {
            try
            {
                LinkedInServiceProvider linkedInServiceProvider = new LinkedInServiceProvider(LinkedInApiKey, LinkedInApiSecret);

#if NET_4_0
                /* OAuth 'dance' */

                // Authentication using Out-of-band/PIN Code Authentication
                Console.Write("Getting request token...");
                NameValueCollection parameters = new NameValueCollection();
                //parameters.Add("scope", "r_basicprofile r_emailaddress");
                OAuthToken oauthToken = linkedInServiceProvider.OAuthOperations.FetchRequestTokenAsync("oob", parameters).Result;
                Console.WriteLine("Done");

                string authenticateUrl = linkedInServiceProvider.OAuthOperations.BuildAuthorizeUrl(oauthToken.Value, null);
                Console.WriteLine("Redirect user for authentication: " + authenticateUrl);
                Process.Start(authenticateUrl);
                Console.WriteLine("Enter PIN Code from LinkedIn authorization page:");
                string pinCode = Console.ReadLine();

                Console.Write("Getting access token...");
                AuthorizedRequestToken requestToken     = new AuthorizedRequestToken(oauthToken, pinCode);
                OAuthToken             oauthAccessToken = linkedInServiceProvider.OAuthOperations.ExchangeForAccessTokenAsync(requestToken, null).Result;
                Console.WriteLine("Done");

                /* API */

                ILinkedIn linkedIn = linkedInServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

                LinkedInProfile profile = linkedIn.ProfileOperations.GetUserProfileAsync().Result;
                Console.WriteLine("Authenticated user is " + profile.FirstName + " " + profile.LastName);

                // Use step by step debugging

/*
 *              LinkedInProfile profileById = linkedIn.ProfileOperations.GetUserProfileByIdAsync("x9HPDDi8DL").Result;
 *              LinkedInProfile profileByPublicUrl = linkedIn.ProfileOperations.GetUserProfileByPublicUrlAsync("http://www.linkedin.com/in/bbaia").Result;
 *              LinkedInProfiles connections = linkedIn.ConnectionOperations.GetConnectionsAsync().Result; // Requires 'r_network' permission
 *              NetworkStatistics statistics = linkedIn.ConnectionOperations.GetNetworkStatisticsAsync().Result; // Requires 'rw_nus' permission
 *              GroupMemberships groups = linkedIn.GroupOperations.GetGroupMembershipsAsync().Result; // Requires 'rw_groups' permission
 */
                // Consume LinkedIn endpoints that are not covered by the API binding

                string    stringResult = linkedIn.RestOperations.GetForObjectAsync <string>("company-search?keywords=SpringSource&format=json").Result;
                JsonValue jsonResult   = linkedIn.RestOperations.GetForObjectAsync <JsonValue>("job-search?job-title=LinkedIn&country-code=FR&format=json").Result;
            }
            catch (AggregateException ae)
            {
                ae.Handle(ex =>
                {
                    // TODO: Update after error handler implementation
                    if (ex is Spring.Rest.Client.HttpResponseException)
                    {
                        Console.WriteLine(ex.Message);
                        Console.WriteLine(((Spring.Rest.Client.HttpResponseException)ex).GetResponseBodyAsString());
                        return(true);
                    }
                    return(false);
                });
            }
#else
                /* OAuth 'dance' */

                // Authentication using Out-of-band/PIN Code Authentication
                Console.Write("Getting request token...");
                OAuthToken oauthToken = linkedInServiceProvider.OAuthOperations.FetchRequestToken("oob", null);
                Console.WriteLine("Done");

                string authenticateUrl = linkedInServiceProvider.OAuthOperations.BuildAuthorizeUrl(oauthToken.Value, null);
                Console.WriteLine("Redirect user for authentication: " + authenticateUrl);
                Process.Start(authenticateUrl);
                Console.WriteLine("Enter PIN Code from LinkedIn authorization page:");
                string pinCode = Console.ReadLine();

                Console.Write("Getting access token...");
                AuthorizedRequestToken requestToken = new AuthorizedRequestToken(oauthToken, pinCode);
                OAuthToken oauthAccessToken         = linkedInServiceProvider.OAuthOperations.ExchangeForAccessToken(requestToken, null);
                Console.WriteLine("Done");

                /* API */

                ILinkedIn linkedIn = linkedInServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

                LinkedInProfile profile = linkedIn.ProfileOperations.GetUserProfile();
                Console.WriteLine("Authenticated user is " + profile.FirstName + " " + profile.LastName);

                // Use step by step debugging

/*
 *              LinkedInProfile profileById = linkedIn.ProfileOperations.GetUserProfileById("xO3SEJSVZN");
 *              LinkedInProfile profileByPublicUrl = linkedIn.ProfileOperations.GetUserProfileByPublicUrl("http://www.linkedin.com/in/bbaia");
 *              LinkedInProfiles connections = linkedIn.ConnectionOperations.GetConnections(); // Requires 'r_network' permission
 *              NetworkStatistics statistics = linkedIn.ConnectionOperations.GetNetworkStatistics(); // Requires 'rw_nus' permission
 */
                // Consume LinkedIn endpoints that are not covered by the API binding

/*
 *              string stringResult = linkedIn.RestOperations.GetForObject<string>("company-search?keywords=SpringSource&format=json");
 *              JsonValue jsonResult = linkedIn.RestOperations.GetForObject<JsonValue>("job-search?job-title=LinkedIn&country-code=FR&format=json");
 */
            }
Example #5
0
 /**
  * Set the delegate implementation.
  *
  * @param _delegate The delegate implementing platform specific functions.
  */
 public void SetDelegate(ILinkedIn _delegate)
 {
     this._delegate = _delegate;
 }
Example #6
0
 /**
  * Constructor with delegate.
  *
  * @param _delegate The delegate implementing platform specific functions.
  */
 public LinkedInBridge(ILinkedIn _delegate) : base()
 {
     this._delegate = _delegate;
 }