MEAN-Stack - UnauthorizedError: No authorization token was found [closed] - mongodb

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 5 years ago.
Improve this question
I want to add User Registration and Login into my Angular2-App.
I found this great tutorial from Jason Watmore . I cloned his repo and checked everything according to his tutorial and also tried the suggestions in his comments.
But still, when i want to access the page at all I get the error below. There seem to be more people with the same problem.
My MongoDB is v3.4.1
Do you have any hints for me? Thanks!
UnauthorizedError: No authorization token was found
at middleware (...\server\node_modules\express-jwt\lib\index.js:80:21)
at ...\server\node_modules\express-unless\index.js:47:5
at Layer.handle [as handle_request] (...\server\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (...\server\node_modules\express\lib\router\index.js:317:13)
at ...\server\node_modules\express\lib\router\index.js:284:7
at Function.process_params (...\server\node_modules\express\lib\router\index.js:335:12)
at next (...\server\node_modules\express\lib\router\index.js:275:10)
at jsonParser (...\server\node_modules\body-parser\lib\types\json.js:103:7)
at Layer.handle [as handle_request] (...\server\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (...\server\node_modules\express\lib\router\index.js:317:13)
Console says:
GET http://localhost:3000/ 401 (Unauthorized)

The route is protected from your backend aka your server.js
your server which im assuming is being run on port 3000 is protected unless you provide a token on your indicated method to which your authorizer will extract from usually its the headers.
to over come this i recommend getting a token from aka do a request that will produce one, usually there's a route setup and you can use postman to post data to get a token, once you have a token use postman to send a get request to that same route you couldn't get access to but make sure you add the header authorization or w.e it's looking for the token on. then you'll get access.

Related

Sending Post Request to server in flutter [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 years ago.
Improve this question
I want send an post request to Api server to update my article views count. I am able to do this via Postman by running http://127.0.0.1:8000/api/updateViews/19 (19 is article id).
I tried http.post() method but could not send request to server.
I just want to send post request whenever anyone open the article detail page.
below is the sample code for flutter post request using http package.
var response = await http.post('http://127.0.0.1:8000/api/updateViews/19',
body:{your post body goes here},
headers : {headers as per your backend needs}
);
after above code you can handle the result of the post request, you can send some success code and error code as response from backend.
for further knowledge visit

Facebook privacy policy URL: Bad Response Code: URL returned a bad HTTP response code (Using AWS S3 hosted Website)

I recently hosted a website on AWS S3 as a static page. For some unknown, Facebook won't allow me to submit the app using https://www.spotin.io/privacy-policy as an url because of a bad response code.
For now, I just added a simple generic privacy policy until I fix this, but I really need help. I read the other questions in Stack Over flow but their from 2 years ago and I following the given advice but it didn't work.
Here I include Facebook's debugger response image:
Facebook Debugger
Can someone help please?
You seem to use CloudFront. Your page already delivers 404 code as a response:
via https://httpstatus.io/
via Postman
Check your CloudFront setup, especially the Errors section. This alternative question might be of help:
CloudFront got X-Cache: Error from cloudfront with Status Code 200

Workfront AtTask API Authentication Error

I am trying to query the Workfront REST Services from PowerShell
I am using a URL like this
https://ourcompany.attask-ondemand.com/attask/api/v4.0/project/search?apiKey=XYZetc
This returns JSON in both IE and Chrome and works in my Web Service tester.
All this runs behind a corporate proxy obviously.
The PowerShell I am using is
$postResult = Invoke-RestMethod -Uri $URI -Method "GET" -Proxy
http://internalproxyname:80 -ProxyUseDefaultCredentials
This fails with an Error
{"error":{"class":"com.attask.common.AuthenticationException","message":"You
are not currently logged in"}}
This looks like an Error at the attask END not the proxy at our end (I get different errors running this as a non auth user or with mangled credentials passed to the Proxy
The docs suggest I don't need to be logged in if I was using an apiKey. I am not logged in in the browsers I am using (I don't even have a user account on the workfront instance)
I have trawled various blogs and stack answers to no avail. Can anyone point me in the right direction for figuring out what is going on? or what I might be doing wrong.
I have Enabled a trust all certs policy and set the validation callback to Ignore within the powershell
but equally I've tried this with these turned off and also investigated various properties on the ServicePointManager. I can produce any number of different errors/issues but the closest I get seems to be the above.
Oh and the Workfront API docs and examples being wrong didn't help me when I was getting started :-)
many thanks
Steve
OK this was me being stupid. There was a bug in the code generating the URI (an extra slash) and the attask default error response is auth error not mangled request.
For reference the URL needs to be in the form shown in my original post. Don't miss off the api version number and don't use a port number as the code samples show.
Always look for the simple things first (I should remember that)
Doh!

Building custom CookiesResource for http-rest-communication in Tosca

I am trying to access a rest-api from Tosca. For now I am using the "Communicate: Rest over HTTP"-module as described in the manual and in the webinar.
The communication has the following sequence:
At the beginning, the client logs in to the server and receives a session-string in the data part of the packet.
The server then expects this session-string as a cookie in each request.
My problem now is to put this new cookie (for example "session=somerandomdata") into the CookieResource.
Unfortunately the manual only applies to already existing CookieRecources.
My question is now whether it is possible to build a CookieRecource with this new cookie.
Whenever a Set-Cookie-Header is returned from the server, a new cookie resource is created.
Please check the manual here: https://support.tricentis.com/community/manuals_detail.do?lang=en&version=10.0.0&url=tbox/wse_tc_session_cookies.htm --> a new cookie resource is created with the name "myCookieResource". This cookie resource can later on be used in the "send" part.
Does this answer your question?

Exchanging Code for Access Token

I am continually getting a 403 when trying to exchange the code for the access token. I have double checked the URI and it seems to match the scheme prescribed.
Here is the URI I am using:
https://partner.api.beatsmusic.com/oauth2/token?client_secret=HIDDEN&client_id=HIDDEN&redirect_uri=http%3A%2F%2Flocalhost%3A1337%2Fcomplete&code=HIDDEN&grant_type=authorization_code
https://partner.api.beatsmusic.com/oauth2/token?client_secret=HIDDEN&client_id=HIDDEN&redirect_uri=http%3A%2F%2Flocalhost%3A1337%2Fcomplete&code=HIDDEN&grant_type=authorization_code
This looks correct. You do need to send it as a post.