QuestionQ103

Understanding and Using APIs

A resource called /item is secured with OAuth2 authentication. An endpoint called /login must request authentication. Which method must be used to access the resource through the REST API?

  • A Make a GET call to /login that includes the username and password, and retrieve a token to insert into the /item call.
  • B Make a POST call to /login including the user credentials in the message, and retrieve a token to insert into the authorization header of the /item call.
  • C Make a GET call to /item, then make a call to /login that includes the username and password in the body of the message, and wait for the authorization code.
  • D Make a POST call to /item that includes the username and password in the body of the request message, and submit it to request access.
Explanation

OAuth 2.0 token requests are made with HTTP POST to the token endpoint, and the issued access token is used to authenticate requests to protected resources through the Authorization header. RFC 6749 specifies that a client must use POST for access-token requests.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!