Hre's my problem, i open my application in my browser and authenticate to Google. When a user access my application on his computer, he receive this error.
Google.Apis.Requests.RequestError Delegation denied for [email protected] [403] Errors [ Message[Delegation denied for [email protected]] Location[ - ] Reason[forbidden] Domain[global] ] à Google.Apis.Requests.ClientServiceRequest`1.Execute() dans c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis\Apis\Requests\ClientServiceRequest.cs:ligne 102 à ManageGoogle.LoadMailGrid(String query, String folderName) dans C:\Workspaces\SyGED\Dev\WebAppl\Google\ManageGoogle.aspx.vb:ligne 131 à ManageGoogle.trvGMailFolders_NodeClick(Object sender, RadTreeNodeEventArgs e) dans C:\Workspaces\SyGED\Dev\WebAppl\Google\ManageGoogle.aspx.vb:ligne 442 à Telerik.Web.UI.RadTreeView.RaisePostBackEvent(String eventArgument) à System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
In load event of my webpage i call my athenticate method like this :
Protected Sub Authenticate()
Dim datafolder As String = Server.MapPath("App_Data/GoogleService.api.auth.store")
Dim scopes As IList(Of String) = New List(Of String)()
Dim UserId As String = Context.User.Identity.Name.ToString
scopes.Add(DriveService.Scope.Drive)
scopes.Add(GmailService.Scope.MailGoogleCom)
Dim myclientsecret As New ClientSecrets() With { _
.ClientId = CLIENT_ID, _
.ClientSecret = CLIENT_SECRET _
}
Dim flow As GoogleAuthorizationCodeFlow
flow = New GoogleAuthorizationCodeFlow(New GoogleAuthorizationCodeFlow.Initializer() With { _
.DataStore = New FileDataStore(datafolder), _
.ClientSecrets = myclientsecret, _
.Scopes = scopes _
})
Dim uri As String = Request.Url.ToString()
Dim code = Request("code")
If code IsNot Nothing Then
Dim token = flow.ExchangeCodeForTokenAsync(UserId, code, uri.Substring(0, uri.IndexOf("?")), CancellationToken.None).Result
' Extract the right state.
Dim oauthState = AuthWebUtility.ExtracRedirectFromState(flow.DataStore, UserId, Request("state")).Result
Response.Redirect(oauthState)
Else
Dim result = New AuthorizationCodeWebApp(flow, uri, uri).AuthorizeAsync(UserId, CancellationToken.None).Result
If result.RedirectUri IsNot Nothing Then
' Redirect the user to the authorization server.
Response.Redirect(result.RedirectUri)
Else
' The data store contains the user credential, so the user has been already authenticated.
myDriveService = New DriveService(New BaseClientService.Initializer() With { _
.ApplicationName = "Liens Google SyGED", _
.HttpClientInitializer = result.Credential _
})
myGMailService = New GmailService(New BaseClientService.Initializer() With { _
.ApplicationName = "Liens Google SyGED", _
.HttpClientInitializer = result.Credential _
})
End If
End If
End Sub
What's wrong with my code ?