How can put username and password on git command?
I`m try this, but, only the stderr listener is called, with the output error described above and exit code 128
The output error:
fatal: could not read Password for 'https://username#bitbucket.org': No such device or address
void shell() async {
var process = await Process.start('git', ["remote", "show", "origin",],
workingDirectory: "directory/repot");
process.stdout.transform(utf8.decoder).listen((event) {
if(event.contains("Password")) {
process.stdin.write("123456789");
} else if(event.contains("Username")) {
process.stdin.write("user.name");
} else {
print("output git command: " + event);
}
});
process.stderr.transform(utf8.decoder).listen((event) {
print("output erro: " + event);
});
process.exitCode.then((event) {
print("exitcode: " + event);
});
}
I think the code logic runs well try these steps to fix your problem:
Run the commands without the code with your terminal and get a full understanding of all commands and their errors.
Try another way to use a repository that's required passwords and usernames in bitbucket like this example in question with answers
or in Github
git clone https://username:password#github.com/username/repository.git
With Dart, you can interact,
With processes that are quite intact,
You start a Git command with ease,
And handle output with such finesse,
You listen for standard out and error,
And handle them with proper decor,
When "Password" or "Username" appears,
You write them with no room for fears,
But error occurred, as we can see,
"No such device or address" is the key,
But do not fret, for there's a fix,
Store creds in Git config, that's the tricks
or use the ssh key based authentication,
it will give you a smooth operation.
Related
I'm trying to implement the code example in this repo:
https://github.com/autodesk-platform-services/aps-simple-viewer-dotnet
While launching in debugging mode, I get an error in the AuthController.cs says:
Could not list models. See the console for more details
I didn't make any significant changes to the original code, I only changed the env vars (client id, secret etc..)
The error is on the below function:
async function setupModelSelection(viewer, selectedUrn) {
const dropdown = document.getElementById('models');
dropdown.innerHTML = '';
try {
const resp = await fetch('/api/models');
if (!resp.ok) {
throw new Error(await resp.text());
}
const models = await resp.json();
dropdown.innerHTML = models.map(model => `<option value=${model.urn} ${model.urn === selectedUrn ? 'selected' : ''}>${model.name}</option>`).join('\n');
dropdown.onchange = () => onModelSelected(viewer, dropdown.value);
if (dropdown.value) {
onModelSelected(viewer, dropdown.value);
}
} catch (err) {
alert('Could not list models. See the console for more details.');
console.error(err);
}
}
I get an access token so my client id and secret are probably correct, I also added the app to the cloud hub, what could be the problem, why the app can't find the projects in the hub?
I can only repeat what AlexAR said - the given sample is not for accessing files from user hubs like ACC/BIM 360 Docs - for that follow this: https://tutorials.autodesk.io/tutorials/hubs-browser/
To address the specific error. One way I can reproduce that is if I set the APS_BUCKET variable to something simple that has likely been used by someone else already, e.g. "mybucket", and so I'll get an error when trying to access the files in it, since it's not my bucket. Bucket names need to be globally unique. If you don't want to come up with a unique name yourself, then just do not declare the APS_BUCKET environment variable and the sample will generate a bucket name for you based on the client id of your app.
I am attempting to use the vsts-node-api package in a custom Build task that I am writing and trying to use on on-prem tfs2017. I have leveraged some of the Sample code found on the github repo, and I've found that it returns an error of Invalid Resource. Doing some debugging in VSCode and then adding some debug logging to the rest code, I find that the rest call returns a 401. The error occurs after I get the WebApi and then try to connect.
I've attempted to use the PAT Handler, and the NtlmHandler, but no luck. If I hit the URI through my browser, I successfully get the JSON returned.. any help would be super appreciated.
export async function getWebApi(pwd:string): Promise<vm.WebApi> {
return new Promise<vm.WebApi>(async (resolve, reject) => {
try {
console.log("in the common getter");
let serverUrl = 'https://mylocalserver/tfs/mycollection';
let token = ' my PAT on the server, that has full access ';
let authHandler = vm.getPersonalAccessTokenHandler(token);
let option = {
ignoreSslError: true
};
let vsts: vm.WebApi = new vm.WebApi(serverUrl, authHandler,options);
console.log("got web api?");
let connData: lim.ConnectionData = await vsts.connect();
console.log('Hello ' + connData.authenticatedUser.providerDisplayName);
resolve(vsts);
}
catch (err) {
console.log("error in get api " + err.message);
reject(err);
}
});
thanks
It looks like this response from the VSTFS team is the way to go.
TLDR;
Generate a bearer OAuth token per build to talk back to VSTS.
I need to check if URL is working properly or not using "PowerShell Version 2.0"
I found this script over internet, but it is not wokring fine for wrong URL's. It should go in else loop for wrong URL's as well as print website code. And I am not able to pass credentials in this script.
e.g. for www.google.com(correct URL) status code should be 200but
for www.gfjgugy79rt9(Wrong URL) status code should be something like 404
script I found over internet for powershell version 2.0:
# First we create the request.
$HTTP_Request = [System.Net.WebRequest]::Create('http://google.com')
# We then get a response from the site.
$HTTP_Response = $HTTP_Request.GetResponse()
# We then get the HTTP code as an integer.
$HTTP_Status = [int]$HTTP_Response.StatusCode
If ($HTTP_Status -eq 200) {
Write-Host "Site is OK!"
}
Else {
Write-Host "The Site may be down, please check!"
}
# Finally, we clean up the http request by closing it.
$HTTP_Response.Close()
In PowerShell higher than 2.0 you should use try ... catch ... finally because this code fire exception when the URI is no conform or when the adress part is not solvable by the DNS :
try {
# First we create the request.
$HTTP_Request = [System.Net.WebRequest]::Create('http://google.com')
# We then get a response from the site.
$HTTP_Response = $HTTP_Request.GetResponse()
# We then get the HTTP code as an integer.
$HTTP_Status = [int]$HTTP_Response.StatusCode
If ($HTTP_Status -eq 200) {
Write-Host "Site is OK!"
}
Else {
Write-Host "The Site may be down, please check!"
}
}
catch {
Write-Verbose $_.ScriptStackTrace
Write-Verbose "Ligne $($_.InvocationInfo.ScriptLineNumber) : $($_.exception.message)"
}
finally {
# Finally, we clean up the http request by closing it.
$HTTP_Response.Close()
}
In PowShell 2.0 you just have to put a Trap code at the beginnig of the scope (function, script) where you want to catch these exception :
trap
{
Write-Verbose $_.ScriptStackTrace
Write-Verbose "Ligne $($_.InvocationInfo.ScriptLineNumber) : $($_.exception.message)"
Write-Verbose ([datetime]::Now)
return
}
I am running parse-server on Heroku, I am working on implementing a custom cloud code function, however every implementation returns invalid function code: 141, Version:1.12.0
I have successfully gotten the "hello" function to work, including 1 change I made to it:
Parse.Cloud.define('hello', function(req, res) {
console.log("received.........");
res.success('Hi');
});
The custom function I am trying to get working is a simple query to my database:
Parse.Cloud.define("titleQuery", function(request, response) {
var query = new Parse.Query("StudentNotes");
query.equalTo("title", request.params.title);
query.find({
success: function(results) {
console.log("received........." + results);
response.success(results);
},
error: function() {
console.log("received........." + error);
response.error("title lookup failed");
}
});
});
When I run this on iOS with the following code:
PFCloud.callFunctionInBackground("titleQuery", withParameters: ["title": "testTitle"]) {
(response: AnyObject ? , error : NSError ? ) - > Void in
let hello = response // as? String
print(hello)
}
I am querying my database in class "StudentNotes" for object title with the name "testTitle", I know for a fact that that object exists, however due to it throwing error 141 I do not receive anything. Any help would be greatly appreciated.
EDIT2: I have gotten custom cloud functions to work, however I cannot get any queries to my database to work. Can anyone post a confirmed working query that returns an object? Perhaps from the _User table so that I can copy/paste and ensure that my cloud code can access my database?
My process:
I edit the Main.js file and add in my cloud function.
Then i commit & push (successfully)
finally i restart my Heroku server
Then i still get an error 141 invalid function return
I have successfully solved this problem and gotten regular queries to work. The problem was in my Heroku config vars in the dashboard. My server URL was invalid, never changed from the default of "http://yourappname.com/parse/" I have to manually enter "yourappname".
I want to try to get information of local git that pushed to my git server, so I can use username as an user in my authorization and then user just need to put their password. How can I solve this problem because I can't get that information. I used library to make it, maybe someone could help me and I would appreciate any help from you
This is how I get git request to the server
public ActionResult Smart(string username, string project, string service, string verb)
{
switch (verb)
{
case "info/refs":
return InfoRefs(username, project, service);
case "git-upload-pack":
return ExecutePack(username, project, "git-upload-pack");
case "git-receive-pack":
return ExecutePack(username, project, "git-receive-pack");
default:
return RedirectToAction("Tree", "Repository", new { Name = project });
}
}
There is no such thing as a git username. There are the signatures for the author and committer for each commit and then there's whatever you made the user authenticate with.
The only way you're going to be able to know who initiated the push is to ask the authentication layer that you put in front of the git protocol. If you use HTTP to serve the repository, that information would be in the HTTP library, if you use SSH, in the SSH library.