Provide credentials function to used with git2::RemoteCallbacks.credentials
Code extracted from:
with_authentication