SparkleNetworks / LinkedInNET

Sparkle.LinkedInNET will help you query the LinkedIn API with C# :)
https://www.nuget.org/packages/Sparkle.LinkedInNET/
GNU Lesser General Public License v3.0
35 stars 51 forks source link

Getting Access Token #18

Closed EmptyCoffin closed 7 years ago

EmptyCoffin commented 7 years ago

Hi I am using the example in the read me but the task to get the access token never evaluates:

  var redirectUrl = "http://localhost:1900/Pages/Content/LinkedIn.aspx";
  var userToken = await ApiClient.OAuth2.GetAccessTokenAsync(code, redirectUrl);
  return userToken.AccessToken;

image Any help is greatly appreciated

ghost commented 7 years ago

This is nothing to do with this api..this is due to deadlock situation( using async and await keyword). Please give complete method codes

EmptyCoffin commented 7 years ago

Hi Tony Thanks for the quick response. Please see below my code: Page Load: image

OAuth2 method: image

sandrock commented 7 years ago

For your specific project, I would like to suggest not using at all the async/await keywords.

In the OAuth2 method: remove async/await and change this line.

var userToken = ApiClient.OAuth2.GetAccessTokenAsync(...).Result;

Does it work?

EmptyCoffin commented 7 years ago

Unfortunately experiencing the same issues, stuck on waiting on highlighted line image

sandrock commented 7 years ago

Why don't you use GetAccessToken instead of GetAccessTokenAsync?

ghost commented 7 years ago

Yes..exactly..as earlier mentioned this happens due to use of async and await.. As sandrock mentioned you need to use Getaccesstoken only.

EmptyCoffin commented 7 years ago

Oh opps, must of over read that. Thanks all is working now!