I am trying to use the POST https://largescalematrix.router.hereapi.com/v1/matrix API.
Could you please tell me how to use it with the apiKey instead of tokens? An example would be great.
Many thanks in advance.
Martin
Currently Here API provides token as the security reason instead of apiKey/app_code
POST https://largescalematrix.router.hereapi.com/v1/matrix
Authorization: Bearer <TOKEN>
Content-Type: application/json
Body:
{
"origins": [{"lat": 0.0, "lng": 0.0}, {"lat": 0.1, "lng": 0.1}, ...],
"destinations": [...], // if omitted same as origins
"regionDefinition": {
"type": "circle",
"center": {"lat": 0.0, "lng": 0.0},
"radius": 10000
}
}
https://developer.here.com/documentation/large-matrix/dev_guide/topics/get-started/send-request.html
to generate the token kindly send this post request-
https://developer.here.com/documentation/large-matrix/dev_guide/topics/get-started/request-a-token.html
also you can check this post for better understanding of token-vector api, 401 http error code, Signature mismatch. Authorization signature or client credential is wrong
Related
I'm trying to learn how to use this query; I created an API key and used Postman to
Post https://www.googleapis.com/calendar/v3/freeBusy?key="THE_API_KEY"
with this request body:
{
"timeMin": "2022-11-16T00:00:31-00:00",
"timeMax": "2022-11-16T14:00:00-00:00",
"groupExpansionMax": 100,
"calendarExpansionMax": 50,
"items": [
{
"id": "MY_OWN_GMAIL_ADDRESS"
},
{
"id": "OTHER_GMAIL_ADDRESS"
}
]
}
and got this response:
{
"kind": "calendar#freeBusy",
"timeMin": "2022-11-16T00:00:31.000Z",
"timeMax": "2022-11-16T14:00:00.000Z",
"calendars": {
"MY_OWN_GMAIL_ADDRESS": {
"errors": [
{
"domain": "global",
"reason": "notFound"
}
],
"busy": []
},
"OTHER_GMAIL_ADDRESS": {
"errors": [
{
"domain": "global",
"reason": "notFound"
}
],
"busy": []
}
}
}
What am I missing?
The Freebusy: query returns information about weither or not there is an event at the time of the request.
This method does not require authorization when being used against a public google calendar. There are a number of such calendars the holiday calendars are all public. You could also set your own calendar to public if you wish and then you would be able to use use an api key to access it.
API keys give you access to public methods only.
In order to access private user data. You need to be authorized using oauth2 with one of the following scopes.
If you do not have access to a calendar then it will return not found as you cant see it so your not going to be able to find it.
The solution i your case to fix your issue would be to either set the calendar to public and continue to use the api key. You will only be able to preform read actions against the calendar.
Or to switch to using oauth2 and send an authorization header with a bearer token.
Your post didnt include the Authorization header. Did you include it in your Postman Request?
Your need to send your Access Token as a Bearer Token in the Authorization Header
You can see an example for a request here:
https://developers.google.com/calendar/api/v3/reference/freebusy/query?apix=true#try-it
I need to get a FCM registration token value which is on my device - just only to test push notification on my device before publishing it to all users. I know that there is a way to get a token during registration and send it to server, but maybe it's possible to find it in some app data without additional implementation?
Just print token to console and test it using postman.
var token = await FirebaseMessaging.getInstance().getToken();
print("token= "+token);
Then copy the token from the console and post using this api:
URI: https://fcm.googleapis.com/fcm/send
METHOD: POST
HEADERS: {
'Content-Type': 'application/json',
'Authorization': 'key=YOUR_FIREBASE_SERVER_KEY'
}
BODY: {
"notification":{
"body": "TEST MESSAGE",
"title": "TEST MESSAGE",
},
"priority": "high",
"data": {
"id": "1",
"status": "done"
},
"registration_ids": "THE_TOKEN",
},
Don't forget to close your app before sending the fcm request.
I am running the following for our GA reporting v4 API - it works fine without the Ecommerce portion but once I add "ecommerce", it gave me an error.
def get_client_report(analytics):
return analytics.userActivity().search(
body=
{
"viewId": VIEW_ID,
"user": {
"type": "CLIENT_ID",
"userId": "REDACTED"
},
"activityTypes": [
"ECOMMERCE"
],
"dateRange": {
"startDate": "2020-04-02",
"endDate": "2020-04-02"
},
"ecommerce": {
"transaction": {
"transactionId" : "REDACTED"
}
}
}
).execute()
and I get the following error:
https://analyticsreporting.googleapis.com/v4/userActivity:search?alt=json returned "Invalid JSON payload received. Unknown name "ecommerce": Cannot find field.". Details: "[{'#type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'description': 'Invalid JSON payload received. Unknown name "ecommerce": Cannot find field.'}]}]">
Can you help me what is wrong here? Thank you!
your request body doesn't match the expected format. Take a closer look at docs.
only activityTypes field is supported and you cannot filter for a specific transactions ID. you'll have to perform filtering on your side after receiving a response in that case.
I have taken section 2 from a walkthrough on how to authorize with jwt so that I can get an access token from my client and authorize them to use the api. However, I can't seem to get this to work. I keep on getting a 401 message from Postman accompanied by a:
{
"Message": "Authorization has been denied for this request."
}
Tutorial Link: http://bitoftech.net/2014/10/27/json-web-token-asp-net-web-api-2-jwt-owin-authorization-server/
The access token comes from an authorization service I have created in Java, so the first section of the tutorial does not apply to me.
JWT
{
"exp": 1489641048,
"user_name": "testuser",
"authorities": [
"USER"
],
"jti": "2dde11c3-2f06-496c-9b36-4dbf71cdc2e2",
"client_id": "webreport_service",
"scope": [
"USER"
]
}
Web API code snippet
public void ConfigureOAuth(IAppBuilder app)
{
var audience = "webreport_service";
// Api controllers with an [Authorize] attribute will be validated with JWT
app.UseJwtBearerAuthentication(
new JwtBearerAuthenticationOptions
{
AuthenticationMode = AuthenticationMode.Active,
AllowedAudiences = new[] { audience },
IssuerSecurityTokenProviders = new IIssuerSecurityTokenProvider[]
{
new SymmetricKeyIssuerSecurityTokenProvider("Any", "abc123")
}
});
}
It is slightly different from what is on the link in section 2, but that is because I don't base64 encode my secret and I also do not put the issuer in my jwt.
Postman
GET /api/protected HTTP/1.1
Host: localhost:54706
Authenticate: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0ODk2NDEyOTAsInVzZXJfbmFtZSI6InRlc3R1c2VyIiwiYXV0aG9yaXRpZXMiOlsiVVNFUiJdLCJqdGkiOiJlMDNkNWZmZC1hZWI4LTRkODctOGQ3My0zNjhjYjQ2ZDg2OWUiLCJjbGllbnRfaWQiOiJ3ZWJyZXBvcnRfc2VydmljZSIsInNjb3BlIjpbIlVTRVIiXX0.C4hivwA1VF-0GO0xCVUoDIheWQWlAcVWvAzChZTgrHY
Cache-Control: no-cache
Postman-Token: ff628109-d5f4-76e0-41c2-e0c7d377b93f
Any help would be greatly appreciated.
Thanks!
I think so check the following:
Firstly:
Check your secret base64 code. 'abc123' is true?
I'm check your token in jwt.io website on your secret code.
but Invalid Signature
Secondly:
Check your payload value.
What is 'iss' your jwt payload. / your issuer validate set 'Any'
What is 'aud' your jwt payload. / your audience validate set 'webreport_service'
Think about it.
Best regard
I have a problem with parse api. I'm sending this data:
{
"where": {
"deviceType": "android"
},
"data": {
"action": "somestring",
"aps": {
"alert": "some title",
"id": 4353453,
"s": "some_short_string"
}
}
}
to https://api.parse.com/1/push using POST method with headers:
Content-Type: "application/json",
X-Parse-Application-Id: "myid",
X-Parse-REST-API-Key: "mykey",
User-Agent: "PHPWebapiClient"
Api returns mostly status 200, but sometimes it returns 404. Of course in this case notifications wont work, and even don't appear in parse admin. It seems totally random, i can't determine the cause. Interestingly api always return this header:
http_code: "HTTP/1.0 200 Connection established"
no matter what response code is returned.
I tried resending request, but this didn't help.
Is there anyone experiencing similar problems? Please help me sort this out.