Basic Auth header not sent (Swagger) - swagger-2.0

I have a basic auth secured API but after filling in the authentication credentials, it does not apply to request header. I saw"ERROR Server not found or an error occurred " at swagger editor and "401 Unauthorized" on fiddler.
User Name and Pwd : odata and qtkr47PTM3pmzLyEHNrW4DXhhgyjMfM3CKUZfXdn0tk=
Here is my swagger json
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Basic Auth Example",
"description": "An example for how to use Basic Auth with Swagger.\nServer code is available [here](http://navm3.cloudapp.net:90/nav/odata). It's running on NAVM3.\n\n**You can use below User Name and Password for test.**\n* User Name: `ODATA`\n* Password: `qtkr47PTM3pmzLyEHNrW4DXhhgyjMfM3CKUZfXdn0tk=`\n"
},
"host": "navm3.cloudapp.net:90",
"basePath": "/nav/odata",
"schemes": [
"http"
],
"securityDefinitions": {
"basicAuth": {
"type": "basic",
"description": "HTTP Basic Authentication. Works over `HTTP` and `HTTPS`"
}
},
"paths": {
"/": {
"get": {
"security": [
{
"basicAuth": []
}
],
"responses": {
"200": {
"description": "Will send `Authenticated` if authentication is succesful, otherwise it will send `Unauthorized`"
}
}
}
}
}
}

i had the same problem, but the problem was in nodeJS back-end.
If you are using NodeJS, probably the problem it is with CORS. You should enable CORS in NodeJS with Express and everything will work.
To enable the CORS in nodeJS you can add the below code, before of the routes.
var app = express();
app.use(function(req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, UPDATE, DELETE, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
next();
});

try to replace the following part:
"securityDefinitions": {
"basicAuth": {
"type": "basic",
"description": "HTTP Basic Authentication. Works over `HTTP` and `HTTPS`"
}
},
with the following
"securityDefinitions": {
"basicAuth": {
"type": "http",
"scheme": "basic"
}
},
keeping the rest as is
here is the reference https://swagger.io/docs/specification/authentication/basic-authentication/

Related

Integromat app {{connection.param}} not working

I am trying to setup an own App in Integromat
What is required for my App is an URL (and later a Bearer Token) to be entered manually by the user who wants to use my App.
I have the Apps Base:
{
"baseUrl": "{{connection.url}}",
"log": {
"sanitize": ["request.headers.authorization"]
}
}
a Connection:
Parameters:
[
{
"name": "url",
"label": "url",
"type": "text",
"required": true,
"value":"https://my-server"
}
]
and the Scenario:
{
"url": "/api/endpoint",
"method": "GET",
"qs": {},
"headers": "{{connection.headers}}",
"response": {
"output": "{{body}}"
}
}
When i execute, the scenario from my App. The URL seems not to be correctly taken over from the one configured inside the connection parametrs.
Can someone help?
Everything was right. I had to delete the old Connection and create a new one.

The LinkedIn Assets API don't show my upload in the linkedin newfeed

I'm using LinkedIn API to upload media to my Linkedin personal profile. I start with registring my image and I get a successful response.
REQUEST
{
"registerUploadRequest":{
"owner":"urn:li:person:xxx",
"recipes":[
"urn:li:digitalmediaRecipe:feedshare-image"
],
"serviceRelationships":[
{
"identifier":"urn:li:userGeneratedContent",
"relationshipType":"OWNER"
}
],
"supportedUploadMechanism":[
"SYNCHRONOUS_UPLOAD"
]
}
}
RESPONSE
{
"value": {
"uploadMechanism": {
"com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest": {
"headers": {
"media-type-family": "STILLIMAGE"
},
"uploadUrl": "xxxx"
}
},
"mediaArtifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:xxx,urn:li:digitalmediaMediaArtifactClass:feedshare-uploadedImage)",
"asset": "urn:li:digitalmediaAsset:xxx"
}
}
Next step I uploaded my image using curl with a valid access token and the uploadUrl
I get a 201 HTTP response but I see nothing in my LinkedIn profile.
also when I check the status of my upload it shows me a success message.
{"recipes":[{"recipe":"urn:li:digitalmediaRecipe:feedshare-image","status":"AVAILABLE"}],"serviceRelationships":[{"relationshipType":"OWNER","identifier":"urn:li:userGeneratedContent"}],"mediaTypeFamily":"STILLIMAGE","created":1606729082880,"id":"C4D22AQE6h5xe3HYYiQ","lastModified":1606729322981,"status":"ALLOWED"}
So why I can't see my upload in the Linkedin timeline, please? I tried with both image and video but nothing is shown in my newsfeed.
Also, I checked my access token and it contains necessary permission: r_liteprofile, w_member_social
Uploading an asset does not make it available on your profile.
Assets API only uploads the image/video and stores it on LinkedIn platform. You can however use this asset to create a UGC Post to see it on your personal/company profile.
To do that, you'll have to use the ugcPosts API. ie call POST https://api.linkedin.com/v2/ugcPosts with
"media": "urn:li:digitalmediaAsset:XXX", from the Assets API response in the payload.
Example:
{
"author": "urn:li:organization:5590506",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"media": [
{
"media": "urn:li:digitalmediaAsset:XXX", // from the Assets API response
"status": "READY",
"title": {
"attributes": [],
"text": "Sample Video Create"
}
}
],
"shareCommentary": {
"attributes": [],
"text": "Some share text"
},
"shareMediaCategory": "VIDEO"
}
},
"targetAudience": {
"targetedEntities": [
{
"locations": [
"urn:li:country:us",
"urn:li:country:gb"
],
"seniorities": [
"urn:li:seniority:3"
]
}
]
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
Reference: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/ugc-post-api#sample-request

Bad request: Attempting to associate a ugc with an asset that's not owned by the author

I'm trying to migrate my app from LinkedIn API v1 to v2. I'm currently looking at sharing images (natively) to my personal LinkedIn profile.
I'm following the official docs here: https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin#create-an-image-share
To register the image I made the following POST request: to https://api.linkedin.com/v2/assets?action=registerUpload
{
"registerUploadRequest": {
"recipes": [
"urn:li:digitalmediaRecipe:feedshare-image"
],
"owner": "urn:li:person:9PyfTxBTFY",
"serviceRelationships": [
{
"relationshipType": "OWNER",
"identifier": "urn:li:userGeneratedContent"
}
]
}
}
I got the success response:
{
"value": {
"uploadMechanism": {
"com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest": {
"headers": {},
"uploadUrl": "https://api.linkedin.com/mediaUpload/C4D22AQEGOHxBzKUXvw/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&m=AQLhYJm0KOaTCgAAAWhSDplI-Lzlfh7lOsd8D5qBcz0aJ2bf1fwIfnh8ow&app=5212106&sync=0&v=beta&ut=0rKn179ebIA8A1"
}
},
"mediaArtifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C4D22AQEGOHxBzKUXvw,urn:li:digitalmediaMediaArtifactClass:feedshare-uploadedImage)",
"asset": "urn:li:digitalmediaAsset:C4D22AQEGOHxBzKUXvw"
}
}
I successfully uploaded an image as binary using the returned uploadUrl:
curl -i --upload-file PATH_TO_FILE --header "Authorization: Bearer TOKEN" 'https://api.linkedin.com/mediaUpload/C4D22AQEGOHxBzKUXvw/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&m=AQLhYJm0KOaTCgAAAWhSDplI-Lzlfh7lOsd8D5qBcz0aJ2bf1fwIfnh8ow&app=5212106&sync=0&v=beta&ut=0rKn179ebIA8A1'
To confirm that the image is ready for use, I checked the status of the asset with the GET https://api.linkedin.com/v2/assets/C4D22AQEGOHxBzKUXvw which returned
{
"serviceRelationships": [
{
"identifier": "urn:li:userGeneratedContent",
"relationshipType": "OWNER"
}
],
"recipes": [
{
"recipe": "urn:li:digitalmediaRecipe:feedshare-image",
"status": "AVAILABLE"
}
],
"mediaTypeFamily": "STILLIMAGE",
"created": 1547564914979,
"lastModified": 1547564994321,
"id": "C4D22AQEGOHxBzKUXvw",
"status": "ALLOWED"
}
Based on the docs, I can now simply reference the asset URN in the UGC post.
This is the test image post I'm trying to share using the https://api.linkedin.com/v2/ugcPosts endpoint
{
"author": "urn:li:person:9PyfTxBTFY",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "Testing LinkedIn image shares"
},
"shareMediaCategory": "IMAGE",
"media": [
{
"status": "READY",
"description": {
"text": "Some text"
},
"media": "urn:li:digitalmediaAsset:C4D22AQEGOHxBzKUXvw",
"title": {
"text": "Some title"
}
}
]
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
But I keep getting the error:
{
"message": "Attempting to associate a ugc with an asset that's not owned by the author",
"status": 400
}
The above request works perfectly when trying to share a status update or a link attachment.
I haven't tried it with videos yet (similar approach) since I assume I will face the same problem. I haven't tried sharing as an organization either since I need to be accepted to the LinkedIn Marketing Developer Program first.
I can confirm that this has been fixed by the LinkedIn Developer Team. Follow the same steps as above and it should work perfectly, as long as the authenticated user has granted the w_member_social permission.
On the last request I now get 201 Created response with the header X-RestLi-Id containing the link to the new post urn:li:share:6494126499975700480.
https://www.linkedin.com/feed/update/urn:li:share:6494126499975700480
P.S. If you're re-trying an old request / registered upload, it won't work, so make sure you try it with a new asset. I believe the bug was when registering uploads.

Sabre Hotel Content Rest API stopped working

POSTing to https://api.sabre.com/v1.0.0/shop/hotels/content?mode=content yesterday worked fine, but with the same Postman request is failing today.
The fault code is: "Client.InvalidCustomerAppId" (but the Http status code is 200.)
Nothing changed on our end, is it possible that I was using an account that no longer has access to this API?
Full JSON response is:
{
"Fault": {
"faultcode": "{http://schemas.xmlsoap.org/soap/envelope/}Client.InvalidCustomerAppId",
"faultstring": "Field CustomerAppId is invalid",
"detail": {
"StackTrace": [
"com.sabre.universalservices.base.exception.ApplicationException: errors.xml.USG_INVALID_CUSTOMER_APP_ID"
]
}
},
"Links": [
{
"rel": "self",
"href": "https://api.sabre.com/v1.0.0/shop/hotels/content?mode=content"
},
{
"rel": "linkTemplate",
"href": "https://api.sabre.com/<version>/shop/hotels/content?mode=<mode>"
}
]
}

google datastore api explorer example

I am trying to understand
https://developers.google.com/apis-explorer/#p/datastore/v1beta1/datastore.datasets.blindWrite
but I always get
503 Service Unavailable
{
"error": {
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "Backend Error"
}
],
"code": 503,
"message": "Backend Error"
}
}
Can you provide a example as simple as possible I can paste to verify it actually works?
I tried something like this.
{
"mutation": {
"insertAutoId": [
{
"key": {
"path": [
{
"kind": "person",
"name": "gert"
}
]
}
}
]
}
}
Assuming that you followed one of the first two activation flows described in the documentation. And created the project recently, an App Engine application should be already associated with your project.
You need to:
Click Authorize your request using OAuth 2.0
Leave https://www.googleapis.com/auth/userinfo.email scope checked
Add https://www.googleapis.com/auth/datastore under Add additional scopes (optional)
Click Authorize and grant the permission
Specify the datasetId parameter (same as your project-id)
Use insert or upsert instead of insertAutoId if the key is complete (kind w/ name or id).
Example:
POST https://www.googleapis.com/datastore/v1beta1/datasets/my-dataset-id/blindWrite...
Content-Type: application/json
Authorization: Bearer ...
X-JavaScript-User-Agent: Google APIs Explorer
{
"mutation": {
"insert": [
{
"key": {
"path": [
{
"kind": "Foo",
"name": "iamfoo"
}
]
}
}
]
}
}
200 OK
{
"kind": "datastore#blindWriteResponse",
"mutationResult": {
"indexUpdates": 1
}
}

Resources