Thursday, April 29, 2021

Sitecore 10 - Error while getting client credentials token: invalid_client

 This is a very common error while working on Sitecore 10 with SCS, Today again I got this error so I thoughts it's good to write a blog on the error, here is the complete details

The full error is here

SerPush

========================================

Executing: .\CakeFiles\Serialization.ps1 -CMHost "https://yoursite.localhost" -IDHost "https://yoursite.localhost" -CLISecret "Bm1bGYPIO7s5Xt0F" -u

Error while getting client credentials token: invalid_client

Client credentials authentication configured without a client secret. Ensure to set the SITECORE_DEFAULT_CLIENT_SECRET environment variable before using this environment.

Login information has been saved.

Client Credentials: Client Secret was not defined. Must be added to default endpoint.

I tried to reset the config and now got the below error 

You are not authorized to perform the task you are attempting. You may need to be assigned additional permissions.

I restarted PowerShell and run under the admin mode (Although this was already under the Admin mode) that has resolved the issue

Wednesday, April 28, 2021

Sitecore 10 - Issue during the serialization (SCS) push - GraphQL.Common.Response.GraphQLResponse

 Recently, I got the below error while working on Sitecore 10 with content serialization.


Unhandled exception: System.Exception: Unhandled exception

 ---> System.AggregateException: One or more errors occurred. (Error converting value 404 to type 'GraphQL.Common.Response.GraphQLResponse'. Path '', line 1, position 3.) (Error converting value 404 to type 'GraphQL.Common.Response.GraphQLResponse'. Path '', line 1, position 3.) (Error converting value 404 to type 'GraphQL.Common.Response.GraphQLResponse'. Path '', line 1, position 3.) (Error converting value 404 to type 'GraphQL.Common.Response.GraphQLResponse'. Path '', line 1, position 3.) (Error converting value 404 to type 'GraphQL.Common.Response.GraphQLResponse'. Path '', line 1, position 3.) (Error converting value 404 to type 'GraphQL.Common.Response.GraphQLResponse'. Path '', line 1, position 3.)

 ---> Newtonsoft.Json.JsonSerializationException: Error converting value 404 to type 'GraphQL.Common.Response.GraphQLResponse'. Path '', line 1, position 3.

 ---> System.ArgumentException: Could not cast or convert from System.Int64 to GraphQL.Common.Response.GraphQLResponse.

   at Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable(Object value, Type initialType, Type targetType)

   at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast(Object initialValue, CultureInfo culture, Type targetType)

   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)

   --- End of inner exception stack trace ---

   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)

   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)

   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)

   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)

   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)

   at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)

   at GraphQL.Client.Http.Internal.GraphQLHttpHandler.ReadHttpResponseMessageAsync(HttpResponseMessage httpResponseMessage)

   at GraphQL.Client.Http.Internal.GraphQLHttpHandler.PostAsync(GraphQLRequest request, CancellationToken cancellationToken)

   at Sitecore.DevEx.Serialization.Client.Datasources.Sc.SitecoreApiClient.<>c__DisplayClass13_0.<<RunQuery>b__0>d.MoveNext() in C:\BA\4c1e764e9356dfd1\src\Sitecore.DevEx.Serialization.Client\Datasources\Sc\SitecoreApiClient.cs:line 127

--- End of stack trace from previous location where exception was thrown ---

   at Sitecore.DevEx.Configuration.Authentication.OidcAuthenticationProvider.MakeAuthenticatedRequestInternal(HttpClient client, Func`2 requestAction) in C:\BA\4c1e764e9356dfd1\src\Sitecore.DevEx.Configuration\Authentication\OidcAuthenticationProvider.cs:line 80

   at Sitecore.DevEx.Configuration.Authentication.OidcAuthenticationProvider.MakeAuthenticatedRequest(HttpClient client, Func`2 requestAction) in C:\BA\4c1e764e9356dfd1\src\Sitecore.DevEx.Configuration\Authentication\OidcAuthenticationProvider.cs:line 25

   at Sitecore.DevEx.Configuration.Authentication.ClientCredentialsAuthenticationProvider.MakeAuthenticatedRequest(HttpClient client, Func`2 requestAction) in C:\BA\4c1e764e9356dfd1\src\Sitecore.DevEx.Configuration\Authentication\ClientCredentialsAuthenticationProvider.cs:line 90

   at Sitecore.DevEx.Configuration.Models.EnvironmentConfiguration.MakeAuthenticatedRequest(HttpClient client, Func`2 requestAction) in C:\BA\4c1e764e9356dfd1\src\Sitecore.DevEx.Configuration\Models\EnvironmentConfiguration.cs:line 168

   at Sitecore.DevEx.Serialization.Client.Datasources.Sc.SitecoreApiClient.RunQuery(String servicePath, GraphQLRequest request, Boolean assertNoErrors, CancellationToken cancellationToken) in C:\BA\4c1e764e9356dfd1\src\Sitecore.DevEx.Serialization.Client\Datasources\Sc\SitecoreApiClient.cs:line 155

   at Sitecore.DevEx.Serialization.Client.Datasources.Sc.Query.SitecoreTreeDataStore.ExecuteSingleBatchQuery[T](String batchQueryFragment, TreeScope scope, ItemSpec[] specs, CancellationToken cancellationToken) in C:\BA\4c1e764e9356dfd1\src\Sitecore.DevEx.Serialization.Client\Datasources\Sc\Query\SitecoreTreeDataStore.cs:line 402

Investigation - I did the git clean up and I think the cleanup has removed a few files or so

Steps -  I build the solution and it was working fine,  I ran the SerPush command again and now this time got the error that one of the scripts is missing from the Theme Component

did not exist in serialized items (66 subtrees) data store. An empty source indicates that you need to fill that source with data before attempting to push it into a destination. Usually, that means you need to pull an initial data set from Sitecore to fill serialized files before being able to push serialized data into Sitecore.

I restored the missing file and the issue got resolved.

Friday, April 9, 2021

Sitecore settings to open media library in a new tab

 Below are the settings to open the medial library in a separate tab.

        <mediaLibrary>

            <mediaTypes>

                <mediaType name="PDF file" extensions="pdf">

                    <forceDownload>false</forceDownload>

                </mediaType>

                <mediaType name="Word document" extensions="doc">

                    <forceDownload>false</forceDownload>

                </mediaType>

                <mediaType name="Word 2007 document" extensions="docx">

                    <forceDownload>false</forceDownload>

                </mediaType>

            </mediaTypes>

        </mediaLibrary>