locked
Warning: This async method lacks 'await' operators and will run synchronously. RRS feed

  • Question

  • User-1352156089 posted

    Hi All,

    i am trying hard to have the code posted on http://blogs.msdn.com/b/webdev/archive/2013/10/16/get-more-information-from-social-providers-used-in-the-vs-2013-project-templates.aspx work. 

    I have made other posts with no luck at all. This is not actually a duplicate because I am following a different approach. I am used to use VB.net but this time I am using C#.

    When I add the following code taken from the tutorial above into my Startup.Auth.cs the system gives me the following warning message:

    This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. 

    The code is:

     var x = new FacebookAuthenticationOptions();
                x.Scope.Add("email");
                x.Scope.Add("friends_about_me");
                x.Scope.Add("friends_photos");
                x.AppId = "xxxxxxxxxxxxxxx";
                x.AppSecret = "xxxxxxxxxxxxxxxx";
                x.Provider = new FacebookAuthenticationProvider()
                {
                    OnAuthenticated = async context =>
                    {
                        //Get the access token from FB and store it in the database and
                        //use FacebookC# SDK to get more information about the user
                        context.Identity.AddClaim(
                        new System.Security.Claims.Claim("FacebookAccessToken",
                                                             context.AccessToken));
                    }
                };
                x.SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie;
                app.UseFacebookAuthentication(x);

    Where is the problem in your opinion?

    Thanks

    Thursday, December 11, 2014 12:50 PM

Answers

  • User-1352156089 posted

    Thank you Summer,

    unfortunately for me I am giving up with OWIN and Oauth 2.0.

    I'll need to find an alternative way in order to retrieve additional data from Facebook (more than the email) and store it into the database.

    There is no documentation at all on how to add custom Facebook claims and store them into database with WebForms projects. When I port the http://blogs.msdn.com/b/webdev/archive/2013/10/16/get-more-information-from-social-providers-used-in-the-vs-2013-project-templates.aspx code from C# to VB and adapt it to WebForms, many errors are generated and honestly the code is something that should be better explained and supported by examples for all platforms and not only MVC. By the way, not even the "working example" in https://github.com/rustd/FBLogin works so I guess that I will need to wait for more examples or books about this topic and it looks like this system is still too much new and that needs many improvements from all aspects.

    Thank you

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 13, 2014 10:58 AM

All replies