Authorization via token with Angularjs

Asked

Viewed 257 times

0

I saw that to set the 'Authorization' field of the header with Angular is used:

$http.defaults.headers.common.Authorization = "Bearer " + token

or

$http.defaults.headers.common.Authorization = "Basic " + token

What is the difference between 'Bearer' and 'Basic'? And why when I request via Postman do not need to concatenate the token with either?

1 answer

1


Basic and Digest authentication are dedicated to authentication using a "login" and a "password".

Bearer authentication is dedicated to using token to authenticate.

Postman’s doubt depends on the way you are authenticating in the case of Basic would not need to pass any token but in the "Body" of the request would be necessary to inform the "login" and "password".

  • In Postman, Seto in header tab only the 'Authorization' token'

  • I don’t think we understand, I use the "Headers" tab of Postman, not the "Authorization" tab. And in the "Headers" tab I have to put the "key" Authorization and in the "value" I have to put "Bearer token" ( Bearer "space" token)

  • Exactly what you said: In the "Headers" tab, I put in the key 'Authorization' with the value 'token' [without bearer] and return me normal.

  • Do you have access to the server? Bearer is defined by the Oauth2 specification can be some configuration in the application that makes you get access even without putting the Bearer in front of the token.

  • I do, but I think now you killed the question. Because probably the application has not been developed using the Oauth standard.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.