Cal Web API with headers authorization [closed] - ajax

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I request web api from html view with header authorization
But unfortunately when i put this section headers
{authorization:'basic fdgxvgxsa='}
in my ajax request it is not make any request
My ajax call is as following
$.ajax{
Url:http/localhost:1234/api/isuserauthinticated
Headers:{'authorization..... '}

You can use beforeSend function to set you autherization headers in .
$.ajax({
type: "POST",
beforeSend: function(request) {
request.setRequestHeader("authorization", authorizationToken);
}
});

Related

I am receiving Fatal error: Uncaught Twilio\Exceptions\TwilioException: Unknown domain message using Twilio [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 days ago.
Improve this question
I am using Twiio API for sending SMS but I when I send a SMS i recieve an error
Fatal error: Uncaught Twilio\Exceptions\TwilioException: Unknown domain message
Fatal error: Uncaught Twilio\Exceptions\TwilioException: Unknown domain message in C:\xampp\htdocs\TwilioSMS\vendor\twilio\sdk\Twilio\Rest\Client.php:920 Stack trace: #0 C:\xampp\htdocs\TwilioSMS\sms.php(12): Twilio\Rest\Client->__get('message') #1 {main} thrown in C:\xampp\htdocs\TwilioSMS\vendor\twilio\sdk\Twilio\Rest\Client.php on line 920

ajax success status code "200" vs "200 OK" [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I am facing some issue related to ajax success status code.in local environment ajax success status code return "200" and live website return status code "200 OK"
what is different between both status code.
Hope this will help you!
There is no difference between 200 and 200 ok.
'OK' is just a message with response code 200. In simple term, it is just a success message.
The best part is even you can modify the message(ok) with some interesting message like 'The user has been created.' for the response code 200
Technically, the request was OK and the server was able to respond properly.
Status code and status message are configurable from the back end. I guess your live server is configured to not send a status message

oauth token request errors with "missing required parameter 'client_id'", [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 9 months ago.
Improve this question
I'm trying to get a token from squares oauth. I can successfuly get the code but when i try to get the token i receive the error "missing required parameter 'client_id'".
I can successfully get a token from postman but not sure why oauth2.Exchange is not passing all info to the oauth server when I try to do it programmatically.
here is a gist of my oauth2.Config object: https://gist.github.com/yshuman1/dedaead8568e695df7a06f86cd986c2d
here is a gist of my failing callback function:
https://gist.github.com/yshuman1/2b496e0fe698a5a0df087c60f4583677
Here is a gist of the redirect & callback functions as well as the oauth2.Config object: https://gist.github.com/yshuman1/b3c472978a4b1b73d6668dfe583f440f
In the callback gist, i also attempted passing in context.TODO() instead of context.Background().
any advice would be appreciated!
I've tried passing the missing items in but not sure what to do to get it done correctly.
I expect to receive a oath token back but dont. I'm getting the error
{
"message": "missing required parameter 'client_id'",
"type": "bad_request.missing_parameter"
}
i ended up solving this by replacing the .Exchange method used to obtain a token with a simple http.POST request to obtain it.
Set the parameter as
{"client_id":client_id}
Pass this JSON object as parameter.

Authorization headers not working with cors [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I've been facing this issue for several days now. I'm trying to make a call to my API (api.mywebsite.com) from my website (mywebsite.com), and it works fine until I try to pass the Authorization header. At that point, it's not a simple request anymore, but a preflighted request.
However, at the end the auth headers are not sent, and the input I get is this one:
This is my front end code (JS):
fetch(generalInfo.url.api+"users/"+userId, {
method: 'GET',
headers: {
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"Authorization": "Bearer "+accessToken
},
withCredentials: true
});
While this is a middleware in the API backend:
//Allow the cors from every domain
module.exports = function (req, res, next){
res.setHeader('Access-Control-Allow-Origin', req.host);
res.setHeader('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Authorization');
if(req.method === 'OPTIONS'){
return res.send(200);
}
next();
}
Can anybody help me?
According to https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
In particular, a request is preflighted if any of the following conditions is true:
If, apart from the headers set automatically by the user agent (for example, Connection, User-Agent, or any of the other header with a name defined in the Fetch spec as a “forbidden header name”),
The forbidden headers include:
https://fetch.spec.whatwg.org/#forbidden-header-name
Which has Access-Control-Request-Headers which we can see is being sent with your request. This explains the use of a preflight.
I think the process looks ok - but in your response headers to the preflight i notice the access control allow origin is api.myapp.com whereas in the request if was on port 8888. I think in the response you should have the port number if it's not 80 for http. See https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy. An origin is the same if:
Two pages have the same origin if the protocol, port (if one is specified), and host are the same for both pages. You'll see this referred to as the "scheme/host/port tuple" at times (where a "tuple" is a set of three components that together comprise a whole).
So i think the issue might be that your preflight is saying to the client that only api.myapp.com is allowed but the actual request might be made to http://api.myapp.com:8888 so the origins don't match. Or have I misunderstood what you are trying to do?
You must remove "8888" port of your api url, the api server has to have already a port setted for api.myapp.com address

Configuring Firefox 3.0.x to send a Kerberos token [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 13 years ago.
Improve this question
I'm trying to convince Firefox 3.0.14 to send a Kerberos token. I have configured the service correctly and IE will send a Kerberos token (i.e. starting YI..), but after adding the hostname to the network.negotiate-auth.trusted-uris and network.negotiate-auth.delegation-uris settings in about:config, Firefox only sends an NTLM token. Here's the (cut down) output from Live Headers:
to server ->
GET /testsso.jsp HTTP/1.1
<- from server
HTTP/1.x 401 Unauthorized
WWW-Authenticate: Negotiate
to server ->
GET /testsso.jsp HTTP/1.1
Authorization: Negotiate TlxxxxxxxxQ=
<- from server
HTTP/1.x 401 Unauthorized
WWW-Authenticate: Negotiate
The server is only interested in a Kerberos token, i.e. one starting in YI, so issues the Unauthorized on the second request, at which point Firefox gives up.
I'm using Windows 2003. Any thoughts?
J
Kerberos is disabled on a default firefox.
You can enable it, check out the guide here:
http://grolmsnet.de/kerbtut/firefox.html

Resources