Google C # client library to get refresh token

This was my previous code using a library.

UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets,
                    new[] { 
                    GmailService.Scope.GmailCompose, GmailService.Scope.GmailModify, GmailService.Scope.GmailReadonly
                    },
                "user", 
                CancellationToken.None
                ) ;

      

I am using this in an ASP.NET MVC 4 application. On this assertion it hangs in the browser. I tried to put the logs, no exceptions and no further execution. I looked into this question, and since this is an asynchronous operation, I switched to Visual Studio 2013. But still the same.

Updated code:

UserCredential credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
            GoogleClientSecrets.Load(stream).Secrets,
                new[] { 
                GmailService.Scope.GmailCompose, GmailService.Scope.GmailModify, GmailService.Scope.GmailReadonly
                },
            "user", 
            CancellationToken.None
            ) ;

      

+3


source to share


1 answer


The controller should also be marked asynchronous and return an ie task



public async Task<IHttpActionResult> get(string token){
    //your code here
}

      

+1


source







All Articles