Domanda

The original question has been edited for clarity:

I have a main project that does a git clone https://my.repo.project.git. The project has 2 targets (main target and password helper target). The repository is password protected and will ask for username, followed by a password. The main app calls the git command via the NSTask object.

NSDictionary *environmentDict = [[NSProcessInfo processInfo] environment];

[task setLaunchPath:gitExecutableLaunchPath];
[task setArguments:[NSArray arrayWithObjects:@"clone", @"https://my.repo.project.git"];
[task setCurrentDirectoryPath:path];
[task setEnvironment:environmentDict];

I have followed the concept from this project to enable my password helper target to run automatically when the main target does not have the git credentials stored in the keychain for the repo. All this secondary password helper target does is the following code (for simplicity):

int main (int argc, const char * argv[]) {
    @autoreleasepool {
        NSLog(@"Password helper has been launched");

        char *username = "my_username";
        char *password = "my_password";
        printf("%s\n", username);
        printf("%s\n", password);
    }
    return 0;

I can see in the logs that the password helper app has been launched, but i always get an "Authentication Failed message". Any idea what i am doing wrong? My goal is to develop a credential helper App much like git's git-credential-osxkeychain app. Any help is much appreciated

È stato utile?

Soluzione

Found the solution. Upon checking the console, i notice that that the Askpass target was being called twice. It seems that this was called the first time for the username, and the second time for the password. I used the following code to determine the reason the Askpass target was being called and responded with the appropriate value.

NSArray *args = [[NSProcessInfo processInfo] arguments];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top