Locize saveMissing function failing with 400 request - javascript

Using a free trail account I am receiving 400 error on saving missing translation.
POST https://api.locize.app/missing/-apiKey-/latest/en/translation 400
Where -apiKey- is the api key provide on account creation.
Is this due to being on free account and just assume it works after purchase?
The preflight before this request is successful just not the actual POST.
Using i18n and this config:
i18n.use(Backend).use(LanguageDetector).use(initReactI18next).init({
debug: true,
fallbackLng: "en",
saveMissing: true,
backend: locizeOptions,
});
Then within code for example:
{t("button.new", "New")}

Related

How to capture the headers of a 401 response or request with js o react?

How to capture the headers of a 401 response or request?
The server is returning this 401 to me since it needs a summary authentication, I need to create a hash to send it to the server from the MD5 algorithm, and I need to get the nonce from the 401 response to be able to calculate the MD5 algorithm, any ideas on how extract the headers the WWW-Authenticate nonce ? any ideas ?
I am using the JsSip.js library
work with react js or js
I leave the answer in an image that should censor some things
enter image description here
In order to retrieve the token from the header you should use Axios interceptors to and access it via req.headers,the proper header for a token is headers.authorisation:'Bearer tokenValue', docs
the same thing happens to me, I show you the configuration that I am using, can you tell me please if any information is missing? Since the 401 is not being answered automatically.
My code is:
var socket = new JsSIP.WebSocketInterface('wss://my.server.com/webrtc/')
var configuration = {
sockets: [socket],
uri: 'sip:TestUser#xxx.xx.xxx.xxx:5060',
password: 'xxxxxxx',
//contact_uri: 'sip:TestUser#xxx.xx.xxx.xxx',
}
var ua = new JsSIP.UA(configuration)
ua.start()
Thank you for your answer.

How to make use of delegated service account (that has already gone through obtaining a JWT) to modify domain-wide emails?

What I am presently attempting to achieve is to write a tool in order to update all email addresses on my domain with a given customized Signature that would have its details updated based on a csv file that it is currently drawing from. What I'm hoping to eventually do is to actually get all users under the domain, get each user's details from the Directory, then update those details without actually needing a CSV file.
For now, though, a more fundamental issue comes up, even after I have prepared an access token after going through the entire convoluted flow that is creating a JWT and obtaining an access token through sending a POST request to the OAuth2 endpoint (process not shown, but it's saved as accessToken below), how am I to apply that access token made using the credentials of my pre-prepared service account in order to actually get to modify the appropriate signature of the email I am currently editing? (email seen below as CURRENTEMAIL)
function updateSignature(contentToUpdate){
gapi.auth.setToken(accessToken);
// https://developers.google.com/gmail/api/v1/reference/users/settings/sendAs/patch
return gapi.client.gmail.users.settings.sendAs.patch ({
//"auth": accessToken,
"userId": 'me',
"sendAsEmail": CURRENTEMAIL,
"resource": {
"signature": contentToUpdate
}
}).then(function(response) {
console.log("Response", response);
},
function(err) { console.error("Execute error", err);
});
}
So far, I've gotten idpiframe_initialization_failed errors when attempting to use the service account's client id during initialization, so I believe that's not how to go about using the key, and using the method above has only told me that I need to make any emails that are not my presently-logged-in email (i.e. I am joey#mydomain.com while my target modified email is testaccount#mydomain.com) one of my aliases instead, which doesn't make any sense in the long run. Does anyone know any other means of dealing with this problem?
I've also tried changing the user ID to that of the service account email, but it has only resulted in execute errors where it states that the delegation was denied.
(index):400 Execute error
{result: {…}, body: "{↵ "error": {↵ "errors": [↵ {↵ "domain": "gl…: "Delegation denied for (redacted)"↵ }↵}↵", headers: {…}, status: 403, statusText: null}
body: "{↵ "error": {↵ "errors": [↵ {↵ "domain": "global",↵ "reason": "forbidden",↵ "message": "Delegation denied for (redacted)"↵ }↵ ],↵ "code": 403,↵ "message": "Delegation denied for (redacted)"↵ }↵}↵"
headers: {date: "Wed, 03 Apr 2019 06:01:10 GMT", content-encoding: "gzip", server: "GSE", content-type: "application/json; charset=UTF-8", vary: "Origin, X-Origin", …}
result: {error: {…}}
status: 403
statusText: null
__proto__: Object
I've been researching on this topic for the past few days and this is the only method that has been documented by any means, but it only affects aliases the gmail account that I am presently logged in as, (i.e. if I was to log in as joey#mydomain.com and modify the signature of testaccount#mydomain.com while it is listed as an alias of joey#mydomain.com, the updated signature is reflected there, but not when I actually log in as testaccount#mydomain.com)
Am I using the access token wrong, or what am I supposed to do otherwise?
Please help!
Figured out how to do this. Apparently, the best way to go about ignoring the various different -limited- language options is to just perform HTTP requests using jquery.
This is especially useful given that I'm not presently using Node, and Python doesn't really serve my purposes given that it's been semi-established that I'll need to work with the HTML file that contains the custom signature in the first place.
In any case, I solved this via sending a PATCH request to
[insert google endpoint here]?access_token=[insert access token obtained via JWT flow]
Makes sense, since all these language-specific APIs are basically just doing http requests in the background for us anyway.
Hope this helps anyone else that might be running into the same issue.

Javascript - Cannot post data (using axios), while it works in postman. Why?

EDIT:
Apperently the mistake (in my third example) was the '?' in http://example.herokuapp.com/api/v1/tickets?
After I removed it, it works :)
I am trying to make a post request with axios and when I do it in postman it all works fine, but when I do it in my code, I always get a 500 or 400 back.
In postman my (data is sample data here)
my url:
http://example.herokuapp.com/api/v1/tickets?
in my body inside postman:
pin: 123ABC,
ride_id: 24,
token: XXAAXXAAXX
so then in my code I tried everything.
first try:
return axios.post("http://example.herokuapp.com/api/v1/tickets?pin="123ABC"&ride_id=24&token=XXAAXXAAXX")
Here I get Error: Request failed with status code 400
2nd try:
return axios.post("http://example.herokuapp.com/api/v1/tickets?", {
params: {
pin: "123ABC",
ride_id: 24,
token: "XXAAXXAAXX"
}
third try:
return axios.post("http://example.herokuapp.com/api/v1/tickets?", {
pin: "123ABC",
ride_id: 24,
token: "XXAAXXAAXX"
})
Any help would be so much appreciated!!!
The third way is the correct way to use a post request with axios. Params are associated with get requests.
The reason that your requests are working in Postman but failing on the website could be a CORS error. You can see if it is a CORS error by looking at your network tab and you see that the request that is failing is an OPTIONS request. It should say something along the lines of
http://localhost:8080 is not allowed by Access-Control-Allow-Origin
To fix this you will need to add some lines of code to your node server.
var cors = require('cors')
var app = express()
app.use(cors())
You can look more into cors here: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors and https://www.npmjs.com/package/cors
what lang is used in your backend?
if it is php remember that for external requests you must place
header("Access-Control-Allow-Origin: *");

fine-uploader azure originator in request instead of endpoint

I am attempting to put blobs to azure storage and I believe I have the server side sas and azure CORS set up correctly.
In my html I have
var uploader = new qq.azure.FineUploader({
element: document.getElementById('fine-uploader'),
debug: true,
request: {
endpoint: 'https://mystorage.blob.core.windows.net/mycontainer'
},
signature: {
endpoint: 'https://myserver/sas/'
},
uploadSuccess: {
endpoint: '/success'
},
retry: {
enableAuto: true
},
deleteFile: {
enabled: true
},
cors: {
expected: true,
sendCredentials: true,
},
In debug mode I see fine-uploader azure gets the sas correctly and then attempts to send the put request but instead of going to the azure endpoint as entered, it attempts to send it to the host as per this message.
Request URL:https://myhostsite/project/sr=c&sp=w&sig=Vh/QLKT3xhkbGBsiUAk4U1eEFpAcD87OK9%2BqgGd8cO4%3D&sv=2016-05-31&se=2017-04-26T22%3A34%3A57Z
Request Method:PUT
Status Code:405 Method Not Allowed
Have you permitted PUT request in AllowedMethods while you set CORS rules?
I took your code with Fine Uploader 5.14.2 to upload an image file to Azure storage. It works fine on my site.
And here is a similar question from SO: Azure CORS Configuration

Bad Authentication data on twitter api with http status 200

I am using a twitter library in javascript called codebird-js. I provided my consumer key and token to tweet however I get back code 215 with the http status 200. On the twitter website it says that you usually get this code with http 400 so I dont know the meaning of this. This is the sample code, can anyone give me pointers on why I am getting this error:
<script type="text/javascript">
var cb = new Codebird;
cb.setConsumerKey('xxx','xxx');
cb.setToken('xxx', 'xxx');
var params = {
status: "im trying"
};
cb.__call(
"statuses_update",
params,
function (reply) {
console.log(reply);
});
</script>
215 means
Bad authentication data - Typically sent with 1.1 responses with HTTP code 400. The method requires authentication but it was not presented or was wholly invalid.
source : https://dev.twitter.com/overview/api/response-codes

Categories

Resources