ArgumentException: The 'ClientId' option must be provided. (Parameter 'ClientId') - google-authentication

I am using google authentication in core 3.1. Previously, my code was working fine but after having system format the project is giving me an exception.
*ArgumentException: The 'ClientId' option must be provided. (Parameter 'ClientId')
Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions.Validate()
I have given the Client ID in startup which is like this:
services.AddAuthentication()
.AddGoogle(options =>
{
IConfigurationSection googleAuthNSection =
Configuration.GetSection("Authentication:Google");
options.ClientId = googleAuthNSection["7111841*********"];
options.ClientSecret = googleAuthNSection["uc**************"];
});
Please help me with this

This is a little late but I had this same problem. After beating my head around it I found that the issue (at least for me) was I had pointed the parameter wrong. Make sure your client ID parameter points to a real location and that you don't have anything misspelled.

Related

Moodle - update_moduleinfo - invalid course module id

I'm currently building a new moodle plugin. I'm using add_moduleinfo and update_moduleinfo. To add a new attandance atictivity in a course and update it later on.
Sadly I'm facing the issue that update_moduleinfo always throws an "invalid course module id" error. I already checked the cm entry in my database to ensure im using the right module instance.
I dont really know what to do.
$cm = get_coursemodule_from_instance($moduleName, $activityID, $course->id);
$moduleinfo = update_moduleinfo($cm, $moduleinfo, $course); <-- Error
Thats how I try to update the entry.
I also found that post. Didn't help anything.
Moodle - Invalid course module ID
I found the issue myself:
$moduleinfo->introeditor['format'] = FORMAT_HTML;
$moduleinfo->introeditor['text'] = "INTRO TEXT";
$moduleinfo->coursemodule = $cm->id;
list($cm, $moduleinfo) = update_moduleinfo($cm, $moduleinfo, $course, null);
In order to use this function the above mentioned properties need to exist in order to perform a update.

Why does calling AutoFake.Provide() wipe out fakes already configured with A.CallTo()?

Why does calling fake.Provide<T>() wipe out fakes already configured with A.CallTo()? Is this a bug?
I'm trying to understand a problem I've run into with Autofac.Extras.FakeItEasy (aka AutoFake). I have a partial solution, but I don't understand why my original code doesn't work. The original code is complicated, so I've spent some time simplifying it for the purposes of this question.
Why does this test fail? (working DotNetFiddle)
public interface IStringService { string GetString(); }
public static void ACallTo_before_Provide()
{
using (var fake = new AutoFake())
{
A.CallTo(() => fake.Resolve<IStringService>().GetString())
.Returns("Test string");
fake.Provide(new StringBuilder());
var stringService = fake.Resolve<IStringService>();
string result = stringService.GetString();
// FAILS. The result should be "Test string",
// but instead it's an empty string.
Console.WriteLine($"ACallTo_before_Provide(): result = \"{result}\"");
}
}
If I swap the order of the calls to fake.Provide<T>() and A.CallTo(), it works:
public static void Provide_before_ACallTo()
{
// Same code as above, but with the calls to
// fake.Provide<T>() and A.CallTo() swapped
using (var fake = new AutoFake())
{
fake.Provide(new StringBuilder());
A.CallTo(() => fake.Resolve<IStringService>().GetString())
.Returns("Test string");
var stringService = fake.Resolve<IStringService>();
string result = stringService.GetString();
// SUCCESS. The result is "Test string" as expected
Console.WriteLine($"Provide_before_ACallTo(): result = \"{result}\"");
}
}
I know what is happening, sort of, but I'm not sure if it's intentional behavior or if it's a bug.
What is happening is, the call to fake.Provide<T>() is causing anything configured with A.CallTo() to be lost. As long as I always call A.CallTo() after fake.Provide<T>(), everything works fine.
But I don't understand why this should be.
I can't find anything in the documentation stating that A.CallTo() cannot be called before Provide<T>().
Likewise, I can't find anything suggesting Provide<T>() cannot be used with A.CallTo().
It seems the order in which you configure unrelated dependencies shouldn't matter.
Is this a bug? Or is this the expected behavior? If this is the expected behavior, can someone explain why it works like this?
It isn't that the Fake's configuration is being changed. In the first test, Resolve is returning different Fakes each time it's called. (Check them for reference equality; I did.)
Provide creates a new scope and pushes it on a stack. The topmost scope is used by Resolve when it finds an object to return. I think this is why you're getting different Fakes in ACallTo_before_Provide.
Is this a bug? Or is this the expected behavior? If this is the expected behavior, can someone explain why it works like this?
It's not clear to me. I'm not an Autofac user, and don't understand why an additional scope is introduced by Provide. The stacked scope behaviour was introduced in PR 18. Perhaps the author can explain why.
In the meantime, if possible, I'd Provide all you need to before Resolveing, if you can manage it.

ArangoDB "Spring Data Demo" Tutorial outdated?

Like the title says, is it possible the tutorial at https://www.arangodb.com/tutorials/spring-data/ is outdated? I'm having several problems, but don't know how to workaround the last one:
Part 2, "Save and read an entity"
I get an error: method getId() is undefined.
Workaround: I added a getter in class Character.
Also in "Save and read an entity"
final Character foundNed = repository.findOne(nedStark.getId());
The method findOne(Example) in the type QueryByExampleExecutor is not applicable for the arguments (String)
Workaround: I used find by example:
final Optional<Person> foundNed = repository.findOne(Example.of(nedStark));
Part 1, "Create a Configuration class"
public class DemoConfiguration extends AbstractArangoConfiguration {
Gives me an error:
"No constructor with 1 argument defined in class 'com.arangodb.springframework.repository.ArangoRepositoryFactoryBean'"
Workaround: ?
Can anyone point me in the right direction?
I found the demo project on github: https://github.com/arangodb/spring-data-demo
Number 1: They use a getter too.
Number 2: Was my fault, I did try ArangoRepository (of Character, Integer) but forgot that Id is a string.
Number 3: They don't seem use any Configuration (AbstractArangoConfiguration) class in the source at all although it is still mentioned in that tutorial. I think now the config and connection is handled by spring autoconfigure. Though I would like to know how the Arango driver is set, all I could find that may point further is ArangoOperations.
Anyway it works now, maybe this helps somebody else who is having the same problems.

GetExportedValues<MyType> returns nothing, I can see the parts

I have a strange MEF problem, I tested this in a test project and it all seems to work pretty well but for some reason not working in the real project
This is the exporting code
public void RegisterComponents()
{
_registrationBuilder = new RegistrationBuilder();
_registrationBuilder
.ForTypesDerivedFrom(typeof(MyType))
.SetCreationPolicy(CreationPolicy.NonShared)
.Export();
var catalog = new AggregateCatalog();
catalog.Catalogs.Add(new AssemblyCatalog(typeof(MyType).Assembly, _registrationBuilder));
var directoryCatalog = new DirectoryCatalog(PathToMyTypeDerived, _registrationBuilder);
catalog.Catalogs.Add(directoryCatalog);
_compositionContainer = new CompositionContainer(catalog);
_compositionContainer.ComposeParts();
var exports = _compositionContainer.GetExportedValues<MyType>();
Console.WriteLine("{0} exports in AppDomain {1}", exports.Count(), AppDomain.CurrentDomain.FriendlyName);
}
exports count is 0 :( Any ideas why?
IN the log file I have many of this
System.ComponentModel.Composition Information: 6 : The ComposablePartDefinition 'SomeOthertype' was ignored because it contains no exports.
Though I would think this is ok because I wasn' interested in exporting 'someOtherType'
UPDATE: I found this link but after debuging over it I am not wiser but maybe I m not following up properly.
Thanks for any pointers
Cheers
I just had the same problem and this article helped me a lot.
It describes different reasons why a resolve can fail. One of the more important ones is that the dependency of a dependency of the type you want to resolve is not registered.
What helped me a lot was the the trace output that gets written to the Output window when you debug your application. It describes exactly the reasons why a type couldn't be resolved.
Even with this output. you might need to dig a little bit, because I only got one level deep.
Example:
I wanted to resolve type A and I got a message like this:
System.ComponentModel.Composition Warning: 1 : The ComposablePartDefinition 'Namespace.A' has been rejected. The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced multiple composition errors, with 1 root causes. The root causes are provided below. Review the CompositionException.Errors property for more detailed information.
1) No exports were found that match the constraint:
ContractName Namespace.IB
RequiredTypeIdentity Namespace.IB
Resulting in: Cannot set import 'Namespace.A..ctor (Parameter="b", ContractName="namespace.IB")' on part 'Namespace A'.
Element: Namespace.A..ctor (Parameter="b", ContractName="Namespace.IB") --> Namespace.A --> AssemblyCatalog (Assembly="assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=...")
But I clearly saw a part for Namespace.IB. So, in the debugger, I tried to resolve that one. And I got another trace output. This time it told me that my implementation of Namespace.IB couldn't be resolved because for one of its imports there was a missing export, so basically the same message as above, just with different types. And this time, I didn't find a part for that missing import. Now I knew, which type was the real problem and figure out, why no registration happened for it.

Entity Framework issue when creating unit tests

I am specifically getting the following error:
"The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid."
[TestMethod()]
public void salesOrderFillListTest()
{
SalesOrderController_Accessor target = new SalesOrderController_Accessor();
string orderNumber = "1954120";
SalesOrderData result;
result = target.FillingOrder(orderNumber);
Assert.AreEqual(null, result.ErrorMessage);
Assert.AreEqual(32, result.LineItems.Count);
Assert.AreEqual("WRA-24-NFL-CLEV", result.LineItems[7].ItemNumber);
Assert.AreEqual(2, result.LineItems[7].OrderQuantity);
Assert.AreEqual(1, result.LineItems[7].FillingFilledQty);
Assert.AreEqual(1, result.LineItems[7].FillingRemainQty);
}
The error is coming up on the line:
result = target.FillingOrder(orderNumber);
I'm a junior developer and haven't had much experience with the many possible causes for this error. My App.config page contains the appropriate connection strings. Any ideas where to look for this one?
Thanks!
I was able to successfully run tests found in another test project in the same solution. After looking more carefully I found that there were a few differences between the two connection strings in each project. The data in the failing test project had become antiquated. I updated the connection string and error resolved.
Thanks.