课程: Learning REST APIs

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

REST and Authorization/Authentication

REST and Authorization/Authentication

课程: Learning REST APIs

REST and Authorization/Authentication

- The response you get from a REST API depends on the authorization level you have when you make the request. Most REST APIs provide leveled access meaning all users can submit limited GET, HEAD, and OPTIONS requests. Some users can submit POST requests and a rare few users can submit PUT, PATCH, and DELETE requests. To get a quick view of this we can send two HEAD requests to the same resource. First, an unauthenticated request. For this unauthenticated request the allow header down here on line 10 says, Allow: GET, meaning anyone can send a GET request to this resource but nothing else. Now let's see what happens if I add an authorization header to my requests. To do so I'll go back to my request, type in Authorization: and then say this is basic authorization and provide my user name and my password. Just before I continue, the local WordPress site I'm working with is set up with Basic authentication which is extremely insecure. You can see I'm passing the username password in…

内容