GitHub Clone from VSCode eg-02-react-implicit-grant error /src/hoc/aux invalid argument - docusignapi

This question is regarding the repo for react implicit grant for docusign using react.
https://github.com/docusign/eg-02-react-implicit-grant
When I tried to clone the repo using VSCode, I received an error
Git: fatal: cannot create directory at 'src/hoc/Aux': Invalid argument
When I looked into the repo, there is a file under src/hoc/aux/aux.js which has the text below.
const aux = (props) => props.children;
export default aux;
Is the file aux.js necessary? Because I was able to extract the zip files after skipping to extract aux.js.

I just tried to clone the https://github.com/docusign/eg-02-react-implicit-grant repo using the GitHub desktop and did not have any problems.
I suggest that you download the repo using git directly or use the download zip option from the repo's page.
Re: aux.js
TL;DR. -- Yes, I believe the aux.js is needed.
Details: Unfortunately I'm not a React expert. (Even though I wrote this example.)
The /hoc directory is used for React Higher Order Components. In this case, I'm using it for a simple component that checks to see if the user has a valid token. I believe that the js file is needed. But you can find out by not including it as seeing what happens.
Also, note that I wrote this React example almost a year ago. You'll want to update it to current React best practices.

Try renaming the aux folder and aux.js file inside it to any random name do it preferably in vscode it will let you know which name is allowed and which isn't, worked for me.

Related

Error running Vorto Dashboard for Bosch iot suite

I am trying to run Vorto dashboard on Raspberry Pi to visualize my Bosch IoT "things" data.
In order to run the Vorto Dashboard, I installed npm and nodejs and created the config.json file.
I am getting the below error whenever I try to run the dashboard using the command: sudo vorto-dashboard config.json, knowing that I already added the OAuth2 Client credentials.
No credentials given, can not get things
Could not get the token with given credentials. - StatusCodeError: 400 -
{"error":"unauthorized_client","error_description":"INVALID_CREDENTIALS:
Invalid client credentials"}
I am currently contributing the Vorto Project as an Intern at Bosch. Due to changes in the Vorto-Dashboard we combined and merged the functionality of a previous dashboard with another coexisting updated UI, providing advanced ways to visualize the existing devices.
As the uploaded state was work in progress, we temporarily disabled the config.json methodology and removed existing references from the documentation. Apparently, the reference in the tutorial you found was omitted, sorry for that!
Today, I deployed a new version 0.5.0 of the vorto-dashboard which should work as usual. You are now able to work with either process.env.[...] varibales or a config.json file. Thank you Mena for the quick response!
Feel free to let me know if you need any further help or have additional feedback.
TL;DR
To resolve your issue, store your OAUth credentials as environmental variables.
E.g. in debian et al., export BOSCH_CLIENT_ID=... etc., then start the dashboard in the same terminal.
Context
I was about to ask the same question, as I got the same error message no matter how I referenced the config.json file (relative path, absolute path, no reference, etc.).
For clarification, the tutorial pointing to a config.json resource for storing OAuth credentials is here.
Quoting:
While the dependencies are being installed, create the config.json file and insert client_id, secret and scope from your Already created
OAuth2 Client. The content of the file has to look like this:
{
"client_id": "<YOUR_CLIENT_ID>",
"client_secret": "<YOUR_CLIENT_SECRET",
"scope": "<YOUR_SCOPE>",
"intervalMS": 10000
}
The reference to the config.json file has been removed from the README.md resource in the vorto-dashboard module of vorto-examples.
The latest README.md suggests providing the OAuth credentials through environmental variables:
You can provide your OAuth2 credentials through environment variables.
The three environment variables you have to provide are:
BOSCH_CLIENT_ID
BOSCH_CLIENT_SECRET
BOSCH_SCOPE
[...]
Looking at the source, I can only find an explicit reference to a config.json in the start script entry for package_for_deployment.json (nor anything around the source seems to be consuming, say, argv[2] for that matter).
The AuthToken.js resource in charge of handling OAuth credentials only seems to reference environmental variables through the process.env.[...] references.
Elaboration
This is only speculation at the time of writing, but I suspect the reason why the config.json methodology has been abandoned might have something to do with strengthening security, i.e. not storing OAuth credentials permanently in a file.
If that much is true, then the tutorial page should probably be amended with the latest instructions from the README.md.

Google Cloud Natural Language Example

I have followed the getting started page closely.
https://cloud.google.com/natural-language/docs/reference/libraries#client-libraries-install-php
The example code has the following: $projectId = 'YOUR_PROJECT_ID';
I fill in my project id taken from the json file and the Google console--e.g. "$projectID = 'myproject-197218'" and I always get a fatal error with "Permission Denied."
I have set the env variable, run composer to install the library. And, I created the Google json file. I am running the example in PHP code.
I am running the code on my local server (xampp).
I figured out my problem. The Google Cloud json file was stored on my drive d:, so in the env variable I referenced it as 'GOOGLE_APPLICATION_CREDENTIALS= d:\xampp\htdocs\googapi\mproj.json', it did not work; when I moved it to the root of the c: drive and referenced it there (GOOGLE_APPLICATION_CREDENTIALS=c:proj.json), it worked fine.
Are you sure that the ID of your project is that one? I'm working in Google Cloud and I cannot see this project ID in our database, but if I type "my-project-197218" with a "-" between "my" and "project" I am able to find one project. please, to make sure that this is your correct project ID, run this command in your Google Cloud Shell to get the default project ID:
gcloud config list --format 'value(core.project)' 2>/dev/null

How to download and write a jar file in Node.js?

So I'm working on a Minecraft launcher (because why not, good experience), and I'm stuck when it comes to downloading the libraries.
I have a valid jar URL here. When you download it in the browser, it works fine. But, when you download it with Node.js, 7-zip gives this error when trying to open it:
An attempt was made to move the file pointer before the beginning of the file.
I'm using a module called snekfetch, but I've also tried it with request. Both items gave the same issue. Here's my current test code:
request.get('https://libraries.minecraft.net/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar').then(r => {
fs.writeFileSync('./mything.jar', r.body);
});
Am I doing something wrong to download the jar file?
Okay, so now that I've seen this answer, I need to modify the question. I've gotten it to work using pipes, but I need inline-code because this is a for loop that's downloading (hence my usage of writeFileSync, and in my actual code I use await for the request). Is it even possible to download and write without piping?
It turns out this is an issue with the snekfetch library. Switching to snekfetch v3 fixed it.
You can check out the status of the issue here.

Open a file directly from a GitLab private repository

I have a private repository on a GitLab server and using the SSH I can pull a project using git clone.
But I want to run a script on linux command line directly from the server (more specific, a Drupal / Drush .make file)
I tried to run it using the raw file:
drush make http://server.com/user/project/raw/master/file.make
(for the convenience of non Drupal users let’s say)
curl http://server.com/user/project/raw/master/file.make
Without success. Of course, it returns me the login page.
Is it possible?
With Chris's valuable help, here is how you can run a script (drupal .make file in my case) from a GitLab server. (Probably it works for GitHub but I didn't test it. Maybe the syntax will be a bit different). (Of course this works for any type of script)
It can be done using the authentication tokens. Here is the documentation of the GitLab's API and here is the GitHub's API
For convenient I will use the https://gitlab.com as the example server.
Go to https://gitlab.com/profile/account and find your "Private token"
Then print the list of the projects and find the id of your project you are looking for
curl https://gitlab.com/api/v3/projects?private_token=<your_private_token>
or go there with your browser (a json viewer will help a lot)
Then print the list of the files that are on this project and find the id of your file you are looking for
curl https://gitlab.com/api/v3/projects/<project_id>/repository/tree?private_token=<your_private_token>
Finally get / run the file!
curl https://gitlab.com/api/v3/projects/<project_id>/repository/raw_blobs/<file_id>?private_token=<your_private_token>
In case you want to run the script (drupal .make)
drush make https://gitlab.com/api/v3/projects/<project_id>/repository/raw_blobs/<file_id>?private_token=<your_private_token> <drupal_folder>
(If you are here looking for a workflow to integrate GitLab with Aegir .make platforms without using tokens (maybe SSH?) please make a thread and paste here the link.)
EDIT
You can get the file without the project_id by using the encoded project name. For example the my-user-name/my-project will become: my-user-name%2Fmy-project
Update 2018-12-25:
as long as you're not downloading huge files, this should work:
curl -s -H "Private-Token: <token>" "https://gitlab.com/api/v4/projects/<urlencode("gitlab_username/project_name")>/repository/files/<path/to/file>/raw?ref=<branch_name>"
, a real example, downloading the file /README.md from the private repository https://gitlab.com/divinity76/Yur17, where the web download url is https://gitlab.com/divinity76/Yur17/raw/master/README.md?inline=false, is:
curl -s -H "Private-Token: afF2s1xgk6xcwXHy3J4C" "https://gitlab.com/api/v4/projects/divinity76%2Fyur17/repository/files/README%2Emd/raw?ref=master"
take special note of how the gitlab_username/repo_name was url-encoded, eg / became %2F (you can check how your username & repo name is as url-encoded by opening your browser javascript terminal and write encodeURIComponent("your_username/repo_name"); in the terminal and press enter.)
thanks to Jonathan Hall # gitlab at mg.gitlab.com, and https://docs.gitlab.com/ee/api/repository_files.html , and tvl for helping reach a solution.
Update 2018-12-11: this method no longer works, now it just serves the login page, with a message saying need to log in to continue, even using HTTP 200 OK (shame on them), will update if i find out why ( #XavierStuvw claims it's security concerns related)
i found a much easier way to do it than #tvl 's answer,
first create an access token with API access here: https://gitlab.com/profile/personal_access_tokens ,
then do:
wget --header 'PRIVATE-TOKEN: <token>' 'https://gitlab.com/<username>/<repo>/raw/master/path/to/file.ext'
i found the solution here.
If you would like to access a file from private GitLab, you could use the below approach which worked for me:)
Construct the URL:
https://url/api/v4/projects/projectId/repository/files/fileName/raw?ref=master&private_token=Generated_private_token
url is your Gitlab url ex: git.lab.com.
/api/v4/projects is a constant.
projectId is the projectId of your project, which you can find below the name of your project in gitlab.
/repository/files is again a constant.
fileName is the name of the file ex: sagar.txt
/raw?ref= is a constant and the value of ref can be master or any branch which you would like to take the file from. I am retrieving the file from Master.
Generated_private_token should be generated from gitlab, please follow the steps in mentioned in the link :
Generate Private Token

no such repository on migrating to a new cvs server

I am moving from cvsserv1 to cvsserv2. I am running cvs1.11 on current server on RHEL. I am moving to cvsserv2 which is running ubuntu 12. This is my procedure to port cvs:
zip entire repository on cvsserv1
move zip to cvsserv2
extract zip to /home/users on cvsserv2.
setup cvs service on cvsserve2 in pserver mode.
initialize repository on /home/users/cvsroot by using "cvs -d /home/users/cvsroot init"
connect to cvsserv2 from eclipse using anonymous access to do a test checkout.
I am failing on step6 with the error message "no such repository". What am I doing wrong?
UPDATE
I tried to change the above method, by adopting this http://mazanatti.info/archives/67/ and I was partially successful.
At step 3 (as in that link), after initializing repo on cvsserv2, I copied my repository to /var/lib/cvsd/project1, overwriting CVSROOT folder. Now, after finishing all steps, I was able to connect successfully. However, when I try to check out, I don't see any branches. When I tried to Refresh Tags, I receive the following error:
What is going wrong?
Ok. I figured this one out. For those who might encounter this issue again, here's how I managed to identify and fix it:
Eclipse's cvs client sucks - it doesn't give you much information. (I could be wrong, may be it writes some debug info to eclipse log file - still, I think that error message should have been more descriptive). Anyway, I obtained TortoiseCVS and attempted a checkout and it failed with an error message on the lines of -"failed to obtain dir lock in repository `/home/cvsroot/foo'. This is not the exact message, but it was something like that.
So, all I had to do, was go into my cvs dump from cvsserv1, look for references to that directory (which is a valid path on cvsserv1 but not cvsserv2). I found a reference to it in config file under CVSROOT folder. It was assigned to a property called LockDir. This property was referring to a /home/cvsroot/foo on the older server as a lock directory. All I had to do was comment out this property and restart cvsd. Everything started working just fine after this!

Resources