unable to get response from an api - api

I a requesting an API to get response but it gives below some "JWT_TOKEN_MiSSING" response:
{
"response": {
"ids": "",
"time": 1505890122982,
"error": "JWT_TOKEN_MISSING",
"status": "failure"
}
}
API is: "https://www.viu.com/api/container/load?appid=viu_desktop&iid=9fa3fec0-9457-11e7-bee5-ed8c9b3d7f48&regionid=all&ver=1.0&aver=5.0&fmt=json&contentCountry=in&contentFlavour=telugu&languageid=en&platform=desktop&vuserid=viu-guest-9fa3fec0-9457-11e7-bee5-ed8c9b3d7f48&userid=guest-9fa3fec0-9457-11e7-bee5-ed8c9b3d7f48&ccode=IN&geo=2&id=playlist-24926470&start=0&limit=20&geofiltered=false"
I tried passing all the headers but no luck.

It seems that this API use JWT TOKEN or other tokens (such as HTTP BASIC AUTHENTICATION) to authenticate, you need to know this and add it to your request headers.

Related

Amazon Advertising API throws HTTP 401 Unauthorized

I am trying to generate ads reports
The create report API gives response as
{
"reportId": "amzn1.sdAPI.v1.p44571.6153E22B.2825ae5c-126d-422c-bf10-53d2d601189a",
"recordType": "campaigns",
"status": "IN_PROGRESS",
"statusDetails": "Report is being generated."
}
but the get report status API gives UNAUTHORIZED error
{
"code": "UNAUTHORIZED",
"details": "HTTP 401 Unauthorized",
"requestId": "6C1XJ33DSF546P3XZSD"
}
My first suggestion would be to ensure you’re using a valid access token.
You should also verify correct scope value and clientID in your header.

Custom response in token endpoint in IdentityServer4

API details:.Net Core 3.1 REST API using IdentityServer4 version 3.1.3
I have many APIs which send responses in a specified format.
For e.g. Register endpoint returns below response:
{
"responseCode": 0,
"developerMessage": "Response code not specified.",
"clientMessage": null,
"data": {"id":123},
"exception": null
}
I developed the authentication server using IdentityServer4.
But, my token endpoint returns below response:
{
"access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6Ik...",
"expires_in": 1209600,
"token_type": "Bearer",
"refresh_token": "1u8_VOFHTaeqWEWd6R...",
"scope": "offline_access api1"
}
Now the requirement is that all the endpoints of the API should return the response in the same format.
Which means I need to change the response of the token (or more) endpoints.
I looked into the ICustomTokenResponseGenerator service (mentioned here) but all it does is adding more fields to the response. And it is from IdentityServer3
class CustomTokenResponseGenerator : ICustomTokenResponseGenerator
{
public Task<TokenResponse> GenerateAsync(ValidatedTokenRequest request, TokenResponse response)
{
response.Custom.Add("custom_field", "custom data");
return Task.FromResult(response);
}
}
But, I want to completely change the response.
Is there any other service that I can use to get the below response?
{
"responseCode": 0,
"developerMessage": "Response code not specified.",
"clientMessage": null,
"data":
{
"access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6Ik...",
"expires_in": 1209600,
"token_type": "Bearer",
"refresh_token": "1u8_VOFHTaeqWEWd6R...",
"scope": "offline_access api1"
},
"exception": null
}
As explained in your GitHub ticket:
IdentityServer is an OAuth implementation - what you are suggesting would be incompatible with OAuth and thus is not supported by us.
If you need to change the complete payload to something custom - write some middleware to intercept the response.

google translate API authorisation problem

I am trying to translate some text using GCP translation service with REST api https://translation.googleapis.com/v3
I'm using API key auth method.
url and
Body
https://translation.googleapis.com/v3/projects/my-translator-1122333:translateText?key=thisismykey
{
"content": ["Hello"],
"sourceLanguageCode": "en",
"targetLanguageCode": "ru"
}
However I got
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Could anyone explain me what is wrong I do?
Thanks

Twitter Insights API with Postman

I'm trying to read insights of my Twitter account with Twitter Insights API and when I request to that given end point I get and error called :
{
"errors": [
{
"code": "UNAUTHORIZED_ACCESS",
"message": "This request is not properly authenticated"
}
],
"request": {
"params": {}
}
}
This is the end point I tried :
https://ads-api.twitter.com/2/insights/accounts/:account_id/available_audiences
I used the given credentials like Consumer Key, Secret and Token, Token secret.
Can anyone explain me why I'm getting this error ? And what I should do ?
Here is a screenshot
Header:
You have to check box "Add params to header"
Everything else should be ok. Just check Consumer Key, Consumer Secret,... data

Foursquare API - Tastes

When I try to send a GET request to Foursquare API below, I get "No matching endpoint." error.
I have validated my tokens and everything seems normal. Any advices?
REQUEST URL
https://api.foursquare.com/v2/users/USER_ID/tastes
RESPONSE MESSAGE
{
"meta": {
"code": 404,
"errorType": "endpoint_error",
"errorDetail": "No matching endpoint"
},
"notifications": [
{
"type": "notificationTray",
"item": {
"unreadCount": 0
}
}
],
"response": {}
}
FoursquareAPI twitter account has told me that I needed to pass m=foursquare in addition to version information.
The correct endpoint information is like
https://api.foursquare.com/v2/users/USER_ID/tastes?oauth_token=TOKEN&v=20150420&m=foursquare
The detailed information about v and m parameters are below.
https://developer.foursquare.com/overview/versioning