DD4T webapp using discovery service gets 'invalid_grant'
There are a lot of articles about the 'invalid_grant' error but I didn't find an answer on my situation.
At first, with Postman I am able to get an access token from /token.svc and use it successfully on the discovery service (with the cduser account).
When I run the .NET webapplication (using the DD4T.Providers.DxaModelService package)I get the following error:
[DataServiceClientException: {"error":"invalid_grant"}]
Microsoft.OData.Client.QueryResult.ExecuteQuery() +478
Microsoft.OData.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +254
[DataServiceQueryException: An error occurred while processing this request.]
Microsoft.OData.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +628
Microsoft.OData.Client.DataServiceQuery`1.GetEnumerator() +22
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +220
Microsoft.OData.Client.DataServiceQueryProvider.ReturnSingleton(Expression expression) +530
Sdl.Web.ModelService.ModelServiceClient.GetModelServiceUri(String uri) +146
Sdl.Web.ModelService.ModelServiceClient..ctor() +126
DD4T.Providers.DxaModelService.BaseProvider..ctor(IProvidersCommonServices providersCommonServices) +137
lambda_method(Closure , Object ) +104
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +270
[DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.)]
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +814
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +269
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +110
[DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TridionPageProvider (ReflectionActivator), Services = [DD4T.ContentModel.Contracts.Providers.IPageProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.) (See inner exception for details.)]
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +433
Autofac.Core.Resolving.InstanceLookup.Execute() +180
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +171
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +119
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +269
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +110
[DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = PageFactory (ReflectionActivator), Services = [DD4T.ContentModel.Factories.IPageFactory], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TridionPageProvider (ReflectionActivator), Services = [DD4T.ContentModel.Contracts.Providers.IPageProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.) (See inner exception for details.) (See inner exception for details.)]
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +433
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +155
Autofac.Core.Resolving.InstanceLookup.Execute() +166
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +171
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +119
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +269
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +110
[DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = PageController (ReflectionActivator), Services = [MijnPostNL.Controllers.PageController], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = PageFactory (ReflectionActivator), Services = [DD4T.ContentModel.Factories.IPageFactory], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TridionPageProvider (ReflectionActivator), Services = [DD4T.ContentModel.Contracts.Providers.IPageProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.) (See inner exception for details.) (See inner exception for details.) (See inner exception for details.)]
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +433
Autofac.Core.Resolving.InstanceLookup.Execute() +180
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +171
Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +108
Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) +122
Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters) +70
Autofac.Integration.Mvc.AutofacDependencyResolver.GetService(Type serviceType) +95
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +61
[InvalidOperationException: An error occurred when trying to create a controller of type 'MijnPostNL.Controllers.PageController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +242
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +103
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +263
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +77
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +1122
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +213
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +131
My web.config has the following configuration:
<!-- Configuration of the Discovery Service -->
<add key="discovery-service-uri" value="http://<domain>/discovery.svc" />
<add key="oauth-enabled" value="true" />
<add key="oauth-client-id" value="cduser" />
<add key="oauth-client-secret" value="CDUserP@ssw0rd" />
Do you have any suggestions on how to fix this error?
Update: I had a look at Fiddler and there is no token being requested:
dxa web8.5 dd4t-2 discovery-service
add a comment |
There are a lot of articles about the 'invalid_grant' error but I didn't find an answer on my situation.
At first, with Postman I am able to get an access token from /token.svc and use it successfully on the discovery service (with the cduser account).
When I run the .NET webapplication (using the DD4T.Providers.DxaModelService package)I get the following error:
[DataServiceClientException: {"error":"invalid_grant"}]
Microsoft.OData.Client.QueryResult.ExecuteQuery() +478
Microsoft.OData.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +254
[DataServiceQueryException: An error occurred while processing this request.]
Microsoft.OData.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +628
Microsoft.OData.Client.DataServiceQuery`1.GetEnumerator() +22
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +220
Microsoft.OData.Client.DataServiceQueryProvider.ReturnSingleton(Expression expression) +530
Sdl.Web.ModelService.ModelServiceClient.GetModelServiceUri(String uri) +146
Sdl.Web.ModelService.ModelServiceClient..ctor() +126
DD4T.Providers.DxaModelService.BaseProvider..ctor(IProvidersCommonServices providersCommonServices) +137
lambda_method(Closure , Object ) +104
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +270
[DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.)]
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +814
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +269
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +110
[DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TridionPageProvider (ReflectionActivator), Services = [DD4T.ContentModel.Contracts.Providers.IPageProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.) (See inner exception for details.)]
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +433
Autofac.Core.Resolving.InstanceLookup.Execute() +180
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +171
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +119
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +269
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +110
[DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = PageFactory (ReflectionActivator), Services = [DD4T.ContentModel.Factories.IPageFactory], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TridionPageProvider (ReflectionActivator), Services = [DD4T.ContentModel.Contracts.Providers.IPageProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.) (See inner exception for details.) (See inner exception for details.)]
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +433
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +155
Autofac.Core.Resolving.InstanceLookup.Execute() +166
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +171
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +119
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +269
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +110
[DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = PageController (ReflectionActivator), Services = [MijnPostNL.Controllers.PageController], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = PageFactory (ReflectionActivator), Services = [DD4T.ContentModel.Factories.IPageFactory], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TridionPageProvider (ReflectionActivator), Services = [DD4T.ContentModel.Contracts.Providers.IPageProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.) (See inner exception for details.) (See inner exception for details.) (See inner exception for details.)]
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +433
Autofac.Core.Resolving.InstanceLookup.Execute() +180
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +171
Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +108
Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) +122
Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters) +70
Autofac.Integration.Mvc.AutofacDependencyResolver.GetService(Type serviceType) +95
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +61
[InvalidOperationException: An error occurred when trying to create a controller of type 'MijnPostNL.Controllers.PageController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +242
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +103
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +263
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +77
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +1122
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +213
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +131
My web.config has the following configuration:
<!-- Configuration of the Discovery Service -->
<add key="discovery-service-uri" value="http://<domain>/discovery.svc" />
<add key="oauth-enabled" value="true" />
<add key="oauth-client-id" value="cduser" />
<add key="oauth-client-secret" value="CDUserP@ssw0rd" />
Do you have any suggestions on how to fix this error?
Update: I had a look at Fiddler and there is no token being requested:
dxa web8.5 dd4t-2 discovery-service
The config looks OK and this should work, however I must ask. Did you copy the keys from a pdf maybe? If yes, then try typing them in by hand. See tridion.stackexchange.com/questions/19040/…
– Atila Sos
16 hours ago
Hi @AtilaSos, I retyped the appSettings (keys and values) but I still get the same error.
– Peter van der Lugt
16 hours ago
from the stack trace above: InvalidOperationException: An error occurred when trying to create a controller of type 'MijnPostNL.Controllers.PageController'.Make sure that the controller has a parameterless public constructor.
– Atila Sos
15 hours ago
add a comment |
There are a lot of articles about the 'invalid_grant' error but I didn't find an answer on my situation.
At first, with Postman I am able to get an access token from /token.svc and use it successfully on the discovery service (with the cduser account).
When I run the .NET webapplication (using the DD4T.Providers.DxaModelService package)I get the following error:
[DataServiceClientException: {"error":"invalid_grant"}]
Microsoft.OData.Client.QueryResult.ExecuteQuery() +478
Microsoft.OData.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +254
[DataServiceQueryException: An error occurred while processing this request.]
Microsoft.OData.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +628
Microsoft.OData.Client.DataServiceQuery`1.GetEnumerator() +22
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +220
Microsoft.OData.Client.DataServiceQueryProvider.ReturnSingleton(Expression expression) +530
Sdl.Web.ModelService.ModelServiceClient.GetModelServiceUri(String uri) +146
Sdl.Web.ModelService.ModelServiceClient..ctor() +126
DD4T.Providers.DxaModelService.BaseProvider..ctor(IProvidersCommonServices providersCommonServices) +137
lambda_method(Closure , Object ) +104
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +270
[DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.)]
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +814
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +269
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +110
[DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TridionPageProvider (ReflectionActivator), Services = [DD4T.ContentModel.Contracts.Providers.IPageProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.) (See inner exception for details.)]
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +433
Autofac.Core.Resolving.InstanceLookup.Execute() +180
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +171
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +119
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +269
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +110
[DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = PageFactory (ReflectionActivator), Services = [DD4T.ContentModel.Factories.IPageFactory], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TridionPageProvider (ReflectionActivator), Services = [DD4T.ContentModel.Contracts.Providers.IPageProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.) (See inner exception for details.) (See inner exception for details.)]
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +433
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +155
Autofac.Core.Resolving.InstanceLookup.Execute() +166
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +171
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +119
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +269
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +110
[DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = PageController (ReflectionActivator), Services = [MijnPostNL.Controllers.PageController], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = PageFactory (ReflectionActivator), Services = [DD4T.ContentModel.Factories.IPageFactory], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TridionPageProvider (ReflectionActivator), Services = [DD4T.ContentModel.Contracts.Providers.IPageProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.) (See inner exception for details.) (See inner exception for details.) (See inner exception for details.)]
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +433
Autofac.Core.Resolving.InstanceLookup.Execute() +180
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +171
Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +108
Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) +122
Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters) +70
Autofac.Integration.Mvc.AutofacDependencyResolver.GetService(Type serviceType) +95
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +61
[InvalidOperationException: An error occurred when trying to create a controller of type 'MijnPostNL.Controllers.PageController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +242
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +103
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +263
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +77
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +1122
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +213
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +131
My web.config has the following configuration:
<!-- Configuration of the Discovery Service -->
<add key="discovery-service-uri" value="http://<domain>/discovery.svc" />
<add key="oauth-enabled" value="true" />
<add key="oauth-client-id" value="cduser" />
<add key="oauth-client-secret" value="CDUserP@ssw0rd" />
Do you have any suggestions on how to fix this error?
Update: I had a look at Fiddler and there is no token being requested:
dxa web8.5 dd4t-2 discovery-service
There are a lot of articles about the 'invalid_grant' error but I didn't find an answer on my situation.
At first, with Postman I am able to get an access token from /token.svc and use it successfully on the discovery service (with the cduser account).
When I run the .NET webapplication (using the DD4T.Providers.DxaModelService package)I get the following error:
[DataServiceClientException: {"error":"invalid_grant"}]
Microsoft.OData.Client.QueryResult.ExecuteQuery() +478
Microsoft.OData.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +254
[DataServiceQueryException: An error occurred while processing this request.]
Microsoft.OData.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +628
Microsoft.OData.Client.DataServiceQuery`1.GetEnumerator() +22
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +220
Microsoft.OData.Client.DataServiceQueryProvider.ReturnSingleton(Expression expression) +530
Sdl.Web.ModelService.ModelServiceClient.GetModelServiceUri(String uri) +146
Sdl.Web.ModelService.ModelServiceClient..ctor() +126
DD4T.Providers.DxaModelService.BaseProvider..ctor(IProvidersCommonServices providersCommonServices) +137
lambda_method(Closure , Object ) +104
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +270
[DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.)]
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +814
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +269
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +110
[DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TridionPageProvider (ReflectionActivator), Services = [DD4T.ContentModel.Contracts.Providers.IPageProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.) (See inner exception for details.)]
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +433
Autofac.Core.Resolving.InstanceLookup.Execute() +180
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +171
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +119
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +269
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +110
[DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = PageFactory (ReflectionActivator), Services = [DD4T.ContentModel.Factories.IPageFactory], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TridionPageProvider (ReflectionActivator), Services = [DD4T.ContentModel.Contracts.Providers.IPageProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.) (See inner exception for details.) (See inner exception for details.)]
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +433
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +155
Autofac.Core.Resolving.InstanceLookup.Execute() +166
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +171
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +119
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +269
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +110
[DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = PageController (ReflectionActivator), Services = [MijnPostNL.Controllers.PageController], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = PageFactory (ReflectionActivator), Services = [DD4T.ContentModel.Factories.IPageFactory], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = TridionPageProvider (ReflectionActivator), Services = [DD4T.ContentModel.Contracts.Providers.IPageProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(DD4T.ContentModel.Contracts.Providers.IProvidersCommonServices)' on type 'TridionPageProvider'. ---> An error occurred while processing this request. (See inner exception for details.) (See inner exception for details.) (See inner exception for details.) (See inner exception for details.)]
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +433
Autofac.Core.Resolving.InstanceLookup.Execute() +180
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +171
Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +108
Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) +122
Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters) +70
Autofac.Integration.Mvc.AutofacDependencyResolver.GetService(Type serviceType) +95
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +61
[InvalidOperationException: An error occurred when trying to create a controller of type 'MijnPostNL.Controllers.PageController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +242
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +103
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +263
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +77
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +1122
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +213
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +131
My web.config has the following configuration:
<!-- Configuration of the Discovery Service -->
<add key="discovery-service-uri" value="http://<domain>/discovery.svc" />
<add key="oauth-enabled" value="true" />
<add key="oauth-client-id" value="cduser" />
<add key="oauth-client-secret" value="CDUserP@ssw0rd" />
Do you have any suggestions on how to fix this error?
Update: I had a look at Fiddler and there is no token being requested:
dxa web8.5 dd4t-2 discovery-service
dxa web8.5 dd4t-2 discovery-service
edited 14 hours ago
Rick Pannekoek
17.6k11125
17.6k11125
asked 17 hours ago
Peter van der LugtPeter van der Lugt
802414
802414
The config looks OK and this should work, however I must ask. Did you copy the keys from a pdf maybe? If yes, then try typing them in by hand. See tridion.stackexchange.com/questions/19040/…
– Atila Sos
16 hours ago
Hi @AtilaSos, I retyped the appSettings (keys and values) but I still get the same error.
– Peter van der Lugt
16 hours ago
from the stack trace above: InvalidOperationException: An error occurred when trying to create a controller of type 'MijnPostNL.Controllers.PageController'.Make sure that the controller has a parameterless public constructor.
– Atila Sos
15 hours ago
add a comment |
The config looks OK and this should work, however I must ask. Did you copy the keys from a pdf maybe? If yes, then try typing them in by hand. See tridion.stackexchange.com/questions/19040/…
– Atila Sos
16 hours ago
Hi @AtilaSos, I retyped the appSettings (keys and values) but I still get the same error.
– Peter van der Lugt
16 hours ago
from the stack trace above: InvalidOperationException: An error occurred when trying to create a controller of type 'MijnPostNL.Controllers.PageController'.Make sure that the controller has a parameterless public constructor.
– Atila Sos
15 hours ago
The config looks OK and this should work, however I must ask. Did you copy the keys from a pdf maybe? If yes, then try typing them in by hand. See tridion.stackexchange.com/questions/19040/…
– Atila Sos
16 hours ago
The config looks OK and this should work, however I must ask. Did you copy the keys from a pdf maybe? If yes, then try typing them in by hand. See tridion.stackexchange.com/questions/19040/…
– Atila Sos
16 hours ago
Hi @AtilaSos, I retyped the appSettings (keys and values) but I still get the same error.
– Peter van der Lugt
16 hours ago
Hi @AtilaSos, I retyped the appSettings (keys and values) but I still get the same error.
– Peter van der Lugt
16 hours ago
from the stack trace above: InvalidOperationException: An error occurred when trying to create a controller of type 'MijnPostNL.Controllers.PageController'.
Make sure that the controller has a parameterless public constructor.
– Atila Sos
15 hours ago
from the stack trace above: InvalidOperationException: An error occurred when trying to create a controller of type 'MijnPostNL.Controllers.PageController'.
Make sure that the controller has a parameterless public constructor.
– Atila Sos
15 hours ago
add a comment |
1 Answer
1
active
oldest
votes
Using Fiddler I found out that the TokenService was registered on the localhost domain. That's why the webapplication (which was running on my local machine) couldn't access the TokenService on the development server.
See screenshot below:
I configured the TokenService with a domainname and now it works.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "485"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftridion.stackexchange.com%2fquestions%2f19884%2fdd4t-webapp-using-discovery-service-gets-invalid-grant%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Using Fiddler I found out that the TokenService was registered on the localhost domain. That's why the webapplication (which was running on my local machine) couldn't access the TokenService on the development server.
See screenshot below:
I configured the TokenService with a domainname and now it works.
add a comment |
Using Fiddler I found out that the TokenService was registered on the localhost domain. That's why the webapplication (which was running on my local machine) couldn't access the TokenService on the development server.
See screenshot below:
I configured the TokenService with a domainname and now it works.
add a comment |
Using Fiddler I found out that the TokenService was registered on the localhost domain. That's why the webapplication (which was running on my local machine) couldn't access the TokenService on the development server.
See screenshot below:
I configured the TokenService with a domainname and now it works.
Using Fiddler I found out that the TokenService was registered on the localhost domain. That's why the webapplication (which was running on my local machine) couldn't access the TokenService on the development server.
See screenshot below:
I configured the TokenService with a domainname and now it works.
answered 15 hours ago
Peter van der LugtPeter van der Lugt
802414
802414
add a comment |
add a comment |
Thanks for contributing an answer to Tridion Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftridion.stackexchange.com%2fquestions%2f19884%2fdd4t-webapp-using-discovery-service-gets-invalid-grant%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The config looks OK and this should work, however I must ask. Did you copy the keys from a pdf maybe? If yes, then try typing them in by hand. See tridion.stackexchange.com/questions/19040/…
– Atila Sos
16 hours ago
Hi @AtilaSos, I retyped the appSettings (keys and values) but I still get the same error.
– Peter van der Lugt
16 hours ago
from the stack trace above: InvalidOperationException: An error occurred when trying to create a controller of type 'MijnPostNL.Controllers.PageController'.
Make sure that the controller has a parameterless public constructor.
– Atila Sos
15 hours ago