Updating value rpccorsdomain? - ethereum

How can I update rpccorsdomain value with my private node already mining?
Note
I have already setup it before to point to a url --rpccorsdomain "http://mywebsite.com" and need to update it to different value

You can restart the RPC API using either the console or through a curl command.
In the console, you can issue an admin.stopRPC() and then restart it passing in the new cors value with admin.startRPC(host, port, newCorsList, apis).
If you prefer using curl:
curl -X POST --data '{"method": "admin_stopWS"}' nodeHostName:nodePortNumber
curl -X POST --data '{"method": "admin_startWS", "params": [host, port, cors, apis]}' nodeHostName:nodePortNumber
The full list of available management APIs can be found here.
Alternatively, you can just stop the node and restart it passing in the new cors list via command line options.

Related

Autodek Forge Tutorial

I have been working through the Autodesk Forge Sample App tutorial.
WHen I click the button to connect with my account I get this error;
{"developerMessage":"The required parameter(s) redirect_uri not present in the request","errorCode":"AUTH-008","more info":"https://forge.autodesk.com/en/docs/oauth/v2/developers_guide/error_handling/"}
If you get this error, you probably trying a 3 legged oauth flow. And it means that you did not provide the callback url in the request. Since you did not say which tutorial you have been using, let me point you to 2 sources - the Forge documentation tutorial here or the Learn Forge tutorial here
In both case, it is important to have the callback url defined in the application page on the Forge portal - If you are using your local machine, it should be something like http://localhost:3000/mycallback. The learnforge material tells you to define it as (see here):
http://localhost:3000/api/forge/callback/oauth
where the documentation tutorial says to use
http://sampleapp.com/oauth/callback
but here they assume you own the domain sampleapp.com which is probably not true. You need to replace sampleapp.com by your own domain or the localhost:port when developing your webserver on your local machine. Note it is important to use your true domain vs localhost when you'll run the code on your server, and update both your application page and your code to use the same definition. I usually setup 3 applications (dev: with localhost:3001, staging: with myapp-staging.autod3sk.net, and production: with myapp.autod3sk.net) - this is to avoid to have to edits keys all the time and make the application deployment a lot easier.
Now that your application is setup, you need to use that URL in your request as documented in the Oauth API. But all parameters should be URL encoded, otherwise the / character will be misinterpreted by the server. Failing to pass the correct and encoded URL parameter in the request will result in the error you are seeing.
Here is an example:
https://developer.api.autodesk.com/authentication/v1/authorize \
?response_type=code \
&client_id=MYCLIENT_ID \
&redirect_uri=MY_ENCODE_CALLBACKURL \
&scope=REQUIRED_SCOPES
after replacing the placeholders, it should look like this
https://developer.api.autodesk.com/authentication/v1/authorize\
?response_type=code\
&client_id=oz9f...k2d\
&redirect_uri=http%3a%2f%2flocalhost%3a3000%2fapi%2fforge%2fcallback%2foauth\
&scope=data%3aread
Copy this in your browser, and after logging and the consent page, the service should return to your browser with a URL like this:
http://localhost:3000/api/forge/callback/oauth?code=wroM1vFA4E-Aj241-quh_LVjm7UldawnNgYEHQ8I
Because, we do not have a server yet, the browser will error, but you can clearly see the URL returned to you with a code. You know need to copy that code into another request to get the final token. Here, we will use curl, but ideally both request and the callback should be handled by your server code.
curl 'https://developer.api.autodesk.com/authentication/v1/gettoken' \
-X 'POST' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'client_id=oz9f...k2d' \
-d 'client_secret=eUr...Q1e' \
-d 'grant_type=authorization_code' \
-d 'code=wroM1vFA4E-Aj241-quh_LVjm7UldawnNgYEHQ8I' \
-d 'redirect_uri=http://localhost:3000/api/forge/callback/oauth'
Ideally, all this needs to be done in your server code, like the learnforge tutorial teach you to do.

getting error when trying to enable approle

I followed this tutorial:
https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-install-hashicorp-vault-on-linux/
$ vault auth enable approle
Error enabling approle auth: Error making API request.
URL: POST http://localhost:8200/v1/sys/auth/approle
Code: 400. Errors:
* missing client token
my vault is running in a container and I have exposed it by 8200 port do I need to mount volumes ?
Use VAULT_TOKEN env while interacting with the vault server via vault CLI:
$ export VAULT_TOKEN="....."
That guide is missing the authentication step.
You will need to to provide a header in your curl request, for example
curl --header 'X-Vault-Token: s.5iSwFPh0XQa96MSrBHquCFlH' https://vault.blah/v1/...

How to get an authorization token from JuPyter hub using its REST APIs?

I want to start a notebook server as described here. I learnt that I need to get an auth token from this and so wanted to get the same, I have to use the api as described here. It always states "Method not allowed, 405". I am unable to figure out what is the right way to do this.
I tried the following post requests:
http://MY_JHUB_ON_K8S_SERVER.com/authorizations/token
with the body of JSON/Application:
{
"username": "aviral",
"password": "aviral",
}
The headers are:
[{"key":"Content-Type","name":"Content-Type","value":"application/json","description":"","type":"text"}]
In Postman, I had tried basic auth as well as no auth. In the basic auth, I pasted the username and password, while when there was no auth, I put the same in the json body
I expect to get the token so that I can start a server. Right now, regardless of the permutation and combination, I am getting 405.
This seems to be possible using the oath api endpoint but I wasn't successful.
Instead I run this command on the jupyterhub server to generate a token
jupyterhub token myusername
and then calls should work properly using the rest api:
curl --insecure 'https://myjupyterhubserver:8443/hub/api/users' \
-H 'Authorization: Token mygeneratedtoken'

How to pass an array to a jenkins parameterized job via remote access api?

I am trying to call a Jenkins parameterized job using curl command. I am following Remote API Jenkins.
I have Active choice parameter plugin. One of the parameters of the job is an Active choice reactive parameter.
Here is the screenshot of the job:
I am using the following curl command to trigger it with parameter:
curl -X POST http://localhost:8080/job/active-choice-test/buildWithParameters -u abhishek:token --data-urlencode json='{"parameter": [{"name":"state", "value":"Maharashtra"},{"name":"cities", "value":["Mumbai", "Pune"]}]}'
But I am not able to pass the cities parameter which should be a json array. The above script is giving error.
I am printing the state & cities variable like this:
The job is getting executed and showing error for cities:
Started by user abhishek
Building in workspace /var/lib/jenkins/workspace/active-choice-test
[active-choice-test] $ /bin/sh -xe /tmp/hudson499503098295318443.sh
+ echo Maharashtra
Maharashtra
+ echo error
error
Finished: SUCCESS
Please tell me how to pass array parameter to a jenkins parameterized job while using remote access API?
You may change the value to strings rather than array:
curl -X POST http://localhost:8080/job/active-choice-test/buildWithParameters -u abhishek:token --data-urlencode json='{"parameter": [{"name":"state", "value":"Maharashtra"},{"name":"cities", "value":"Mumbai,Pune"}]}'

Drupal JSON Server and Services Module only returns Invalid Method

I have been trying to get a stock Drupal site up and running with JSON Server module and Services. After install I added the two modules and enabled them. When I use Curl from the command line to call system.connect or anything I only get Invalid Method.
curl --data method=system.connect http://localhost/services/json
This is what I am getting back.
{ "#error": true, "#data": "Invalid method " }
I remember having the same problem myself a while back. Your problem at the moment is that your post data does not have quotes.
curl --data 'method="system.connect"' http://localhost/services/json
If you have a look at this: http://drupal.org/node/305799 it should give you loads more info to get you going with services and the json server.