I am looking for a way to generate token using login/password on reportportal.
Pretty sure, there should be a way using a API call. I am just not able to find it.
So given, (project name, user, password), I should get a token that I can use for making other API calls.
Thanks.
Get API token
Before getting API token, you have to generate it.
If it's already generated (you have logged in with this user), this endpoint will return you existing API token:
GET /sso/me/apitoken
Example:
curl -X GET --header 'Accept: application/json' --header 'Authorization: bearer 4f73871b-e477-4f49-b1bd-805b24201fe0' 'http://web.demo.reportportal.io/uat/sso/me/apitoken'
Response:
{
"access_token": "b1debc0a-d47d-492f-aa7c-3e2e0fb96332",
"token_type": "bearer",
"scope": "api"
}
Pay attention, that bearer in 1st (curl) request has scope UI and bearer in response has scope API.
UI token expires according to server config and TimeToLive for user session.
API token has endless TTL
** If GET requests returns you error, then you need to generate token.
Generate API token
POST sso/me/apitoken
Example:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: bearer 4f73871b-e477-4f49-b1bd-805b24201fe0' 'http://web.demo.reportportal.io/uat/sso/me/apitoken?authenticated=true'
Response:
{
"access_token": "4e76e31e-0250-4e5e-ba66-90105dd014bb",
"token_type": "bearer",
"scope": "api"
}
(!) Tokens are public. Used from public account at demo instance http://web.demo.reportportal.io
Make a post to:
/uat/sso/oauth/token?grant_type=password&password=***password***&username=***username***
Set basic authentication with credentials (username: ui and password: uiman) to get the accesstoken for scope UI, use this token to fetch apitoken.
Related
I need to send message with headers through Artemis Queue.
How could do it.
Headers:--header 'PAYMENT_RE: PAGO-X' \
--header 'Content-Type: application/json' \
--header 'OPERATION_ID: 72ab0c45-7871-4fdc-9cb7-e8644a87372d' \
--header 'ORDER_ID: 242221347' \
11:41
TRACING_HEADERS=[{\"uber-trace-id\":\"1429c44436cbaaa7%3A1dca2e791ce1724c%3A39ca9cdcbc9f1fa6%3A1\"},{\"uber-trace-id\":\"1429c44436cbaaa7%3Ae97e978f0d2e92e9%3A1dca2e791ce1724c%3A1\"},{\"uber-trace-id\":\"1429c44436cbaaa7%3A3f839f45ce8cf16d%3Ae97e978f0d2e92e9%3A1\"},{\"uber-trace-id\":\"1429c44436cbaaa7%3A7cc993c33466cb90%3A3f839f45ce8cf16d%3A1\"},{\"uber-trace-id\":\"1429c44436cbaaa7%3A4b4368e0660b8363%3A7cc993c33466cb90%3A1\"},{\"uber-trace-id\":\"1429c44436cbaaa7%3Abfd4a636acb617cb%3A4b4368e0660b8363%3A1\"},{\"uber-trace-id\":\"1429c44436cbaaa7%3A888811c524eba2fe%3Abfd4a636acb617cb%3A1\"}]
uber-trace-id=1098c66636cbaaa7%4ec2cb277101430ca2f88bbe9f56a3b8%3Abfd1a636acb618cb%3A1'
Body:
{
"correlationId":"",
"refundId":"",
"captureTraceabilityId":"",
"captureCode":"",
"networkId":154644,
"amount":{
"currency":"COP",
"total":10000
},
"route":{
"id":"",
"type":"DEFAULT"
},
"paymentInstrument":{
},
"partialOperation":false,
"finalPartialOperation":false
}
Right now I only can send the body, but I don't know how send the headers:
But I don't know how can be the structure to send the headers.
It's not clear which version of ActiveMQ Artemis you're using, but when I use version 2.24.0 to send a message with the web console I'm presented with the option of adding headers to the message by clicking the "Add Header" button. Here's a screenshot of what it looks like after I click that button and enter some details:
Hi i am developing a google oauth2 login and i dont't know how to get a user info using access token or id token using this urls
https://www.googleapis.com/oauth2/v3/userinfo passsing access token in Authorization header returns this json:
"sub": "100366573866312827626",
"picture": "https://lh3.googleusercontent.com/a/default-user=s96-c"
}
https://www.googleapis.com/oauth2/v3/tokeninfo?id_token={id_token} get this json
{
"iss": "https://accounts.google.com",
"azp": "375890336523-u4rpach5688ltoc0v4mof1r7j70gem95.apps.googleusercontent.com",
"aud": "375890336523-u4rpach5688ltoc0v4mof1r7j70gem95.apps.googleusercontent.com",
"sub": "100366573866312827626",
"at_hash": "htkn2tQqV4Ff4EmrtPDh9w",
"iat": "1636631006",
"exp": "1636634606",
"alg": "RS256",
"kid": "27c72619d0935a290c41c3f010167138685f7e53",
"typ": "JWT"
}
But in both json doesn't have any user information like username or email
thanks for your time and sorry for my english, is not my native languaje
Make sure when you authorized the user that you requested profile scope.
Using the Access token returned when your user authorized your application. You can get the users profile information you should make a call to the People.get method
curl \
'https://people.googleapis.com/v1/people/me?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
The user info endpoint will give you a little bit of info but not as much as using the userinfo endpoint.
Google does not always return the user claims in the id token, so i would not try to rely upon that.
How can I upload a 360 degree image to Google map street view. (I know to take 360 degree photo and upload from street view app).
You may follow this documentation on how to upload photos using curl.
Creating a photo requires three separate calls. The first call will return an upload URL, which is used in the second call to upload the photo bytes. After the photo bytes are uploaded, the third call uploads the metadata of the photo and returns the photo ID.
Request an Upload URL
$ curl --request POST \
--url 'https://streetviewpublish.googleapis.com/v1/photo:startUpload?key=YOUR_API_KEY' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'Content-Length: 0'
Upload the photo bytes to the Upload URL
$ curl --request POST \
--url 'UPLOAD_URL' \
--upload-file 'PATH_TO_FILE' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN'
Upload the metadata of the photo
$ curl --request POST \
--url 'https://streetviewpublish.googleapis.com/v1/photo?key=YOUR_API_KEY' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"uploadReference":
{
"uploadUrl": "UPLOAD_URL"
},
"pose":
{
"heading": 105.0,
"latLngPair":
{
"latitude": 46.7512623,
"longitude": -121.9376983
}
},
"captureTime":
{
"seconds": 1483202694
},
}'
There are also client libraries available which you may use to avoid the need to manually set up HTTP requests and parse the responses.
I have a sample code here. It is json
{
"document":{
"type":"PLAIN_TEXT",
"content":"Joanne Rowling, who writes under the pen names J. K. Rowling and Robert Galbraith, is a British novelist and screenwriter who wrote the Harry Pott$
},
"encodingType":"UTF8"
}
I found a tutorial on google's documentation on Natural Language processing on reading from Google Cloud Storage.
curl -X POST \ -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \ --data "{
'document':{
'type':'PLAIN_TEXT',
'gcsContentUri':'gs://reubucket/textData'
}
}" "https://language.googleapis.com/v1/documents:analyzeEntitySentiment"
And the error that I got is
ERROR: (gcloud.auth) Invalid choice: '*************-_m6csS1Wzlj1pyC_J7vzC0'.
Usage: gcloud auth [optional flags] <group | command>
group may be application-default
command may be activate-service-account | configure-docker | list |
login | revoke
How do I call the command with my API key.
I need a way to change the "content" to entries into my CSV file.
Thank you.
Here is an example of the error that I am receiving please help:
mufaroshumba#reucybertextmining:~/myFolder$ gcloud auth activate-service-account --key-file="/home/mufaroshumba/myFolder/reucybertextmining-74fa66372251.json"
Activated service account credentials for: [starting-*******[CENSORED]#reucybertextmining.iam.gserviceaccount.com]
mufaroshumba#reucybertextmining:~/myFolder$ curl "https://language.googleapis.com/v1/documents:analyzeSentiment?key=${API_KEY}" \ -s -X POST -H "Content-Type: app
lication/json" --data-binary #request.json
{
"error": {
"code": 401,
"message": "Permission to access the GCS address is denied.",
"status": "UNAUTHENTICATED",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "document.gcs_content_uri",
"description": "Permission to access the GCS address is denied."
}
]
}
]
}
}
curl: (6) Could not resolve host: -s
mufaroshumba#reucybertextmining:~/myFolder$
I then used this website trying to get
It looks like your auth is not setup correctly. If you just run this command:
gcloud auth application-default print-access-token
it should be giving you a token, but it seems like it's not. Please follow the steps here to make sure that this command is working first:
https://cloud.google.com/natural-language/docs/quickstart#quickstart-analyze-entities-cli
Then, as long as you have permission to access the gcs bucket, you should be able to get content out of it. Note that the API is expecting to see the actual content in the gcs file, and not a CSV.
I have the following controller I am trying to use Curl to test it. The problem is that fiscalId is always null its not reading my post body from curl.
Controler:
[Route("api/token")]
public class TokenController : Controller
{
[HttpPost("changefiscal")]
[Authorize]
public async Task<ActionResult> ChangeFiscal([FromBody] long fiscalId)
{
//fiscalId is always 0
}
}
I have checked the documentation here which says to use the -d parameter and post it as a json object. Unfortunately thats not working
curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST http://localhost:3000/data
I have tried
curl -d "fiscalId=21875" -H "Content-Type: application/json" -H "Authorization: Bearer XXX" -X POST -i http://localhost:5000/api/token/changefiscal
and
curl -d "{"fiscalId":"21875"}" -H "Content-Type: application/json" -H "Authorization: Bearer XXX" -X POST -i http://localhost:5000/api/token/changefiscal
and
curl -d "{"fiscalId":"21875"}" -H "Content-Type: application/json" -H "Authorization: Bearer XXX" -X POST -i http://localhost:5000/api/token/changefiscal
and
curl -d "{\"fiscalId\":\"21875\"}" -H "Content-Type: application/json" -H "Authorization: Bearer XXX" -X POST -i http://localhost:5000/api/token/changefiscal
and everything else i can think of
I can see in the log that it appears to be sending it
Rebuilt URL to: POST/
timeout on name lookup is not supported
getaddrinfo(3) failed for POST:80
Couldn't resolve host 'POST'
Closing connection 0 curl: (6) Couldn't resolve host 'POST'
timeout on name lookup is not supported
Trying ::1...
TCP_NODELAY set
Trying 127.0.0.1...
TCP_NODELAY set
Connected to localhost (127.0.0.1) port 5000 (#1)
POST /api/token/changefiscal HTTP/1.1
Host: localhost:5000
User-Agent: curl/7.53.1
Accept: /
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjI2OTAzNzc0NjYyNzc4RDM1MzE2QUUwQUU1MjIyQUU1REIzM0M0NUEiLCJ0eXAiOiJKV1QiLCJ4NXQiOiJKcEEzZEdZbmVOTlRGcTRLNVNJcTVkc3p4Rm8ifQ.eyJuYmYiOjE1MTA1NjcxNzMsImV4cCI6MTUxMDU3MDc3MywiaXNzIjoiaHR0cDovL2xvY2FsaG9zdDo1MDAwIiwiYXVkIjpbImh0dHA6Ly9sb2NhbGhvc3Q6NTAwMC9yZXNvdXJjZXMiLCJ0ZXN0YXBpIl0sImNsaWVudF9pZCI6IlNlcnZpY2VBY2NvdW50QWNjZXNzIiwic3ViIjoiMjEyNDg1ODIiLCJhdXRoX3RpbWUiOjE1MTA1NjcxNzMsImlkcCI6ImxvY2FsIiwibmFtZSI6ImxpbGF3IiwiZS1tYWlsIjoibGlsYXdAZWcuZGsiLCJzY29wZSI6WyJvcGVuaWQiLCJwcm9maWxlIiwidGVzdGFwaSJdLCJhbXIiOlsicGFzc3dvcmQiXX0.Q_oJ-xOIKdTtGoRqJbtNjwLV82cQQLhJUVl2Ey-4riZdp45rPIrmfOw9VdknUOLpm8RYZ0iLFC31gCpn1vKb4zLiTmBuTuzYsKxnAvf-UkCj1L8soH4W2lCvx560bZeS7B67tJ4nK9t36OiMLQY4m-_NRTSRBs5QtsXBd5VQGPsTpxf_MxVbQm6Hj6Ot3FGRIa08gmwD3iEr9vsCU6732InbGzU26wtm-WLWp_A_k66Z29G8ms_U8x6gg-aOlQG9_0v_DEjTXCkKNcgWoL0IvaCC0psiYkdIjQxaOwz-e_fcqXpKEFmuoSqmGd1l-eMl3HimOomdOHwqploWGxnJ4Q
Content-Length: 7
upload completely sent off: 7 out of 7 bytes
However when i check fiscalId its always 0 i even tried to change fiscalId to a string and its just null.
When you POST data as JSON object, like -d '{"fiscalId": 21875}', your action method should expect some simple class with corresponding properties. In your case:
public class Dto
{
public long fiscalId {get; set;}
}
and
public async Task<ActionResult> ChangeFiscal([FromBody] Dto data)
Finally after more then an hour of playing with this I got it even though the content-Type is json its just sent as a string "'21875'" even though all the documentation shows sending it as JSon. For some reason the API isnt able to read it as a JSon Object but expects it just to be sent as a string.
curl POST -v -d "'21875'" -H "Content-Type: application/json" -H "Authorization: Bearer XXX" http://localhost:5000/api/token/changefiscal