Reputation: 1300
This was my previous code with the help of library.
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] {
GmailService.Scope.GmailCompose, GmailService.Scope.GmailModify, GmailService.Scope.GmailReadonly
},
"user",
CancellationToken.None
) ;
I'm using this in ASP.NET MVC 4 application. At this statement, it hangs the browser. I tried putting logs, no exception and no further execution is done. I looked at this question, and since it is asynchronous operation, I switched to Visual Studio 2013. But still the same thing.
Updated code:
UserCredential credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] {
GmailService.Scope.GmailCompose, GmailService.Scope.GmailModify, GmailService.Scope.GmailReadonly
},
"user",
CancellationToken.None
) ;
Upvotes: 3
Views: 380
Reputation: 1187
The controller must also be marked with async and return a Task i.e.
public async Task<IHttpActionResult> get(string token){
//your code here
}
Upvotes: 1