cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
728
Views
11
Helpful
1
Replies

The Power of 2

yawming
Cisco Employee
Cisco Employee

The Power of 2 (not about  2 )

yawming_0-1679282872458.png

The number 2 is the smallest and only even prime number. The Chinese consider the number 2 to be lucky. A Chinese proverb says, "good things come in pairs." In the real world, what can you buy with just $2? Can you buy a lottery ticket and win a billion dollars? Perhaps you’ll be lucky and win big. The power of 2 is full of surprises.

Let’s say a person named Deuce is visiting  an aquarium, and the general admission ticket costs $403. He gives all the money in his pocket, which is $401, to the person in the ticket booth, However the person in the ticket booth returns $401 to Deuce and saying, 'Sorry sir , that’s not enough'. The person behind Deuce is kind enough to give him $2, saying, 'It’s only $2, enjoy.' His  lucky day, now, he can buy his ticket and have a good time. Later, he discovers that an interesting 3D movie is starting in 15 minutes in the auditorium. He rushes over there and shows his ticket to the ticket taker, but the ticket taker returns his $403 ticket to him and says, 'Sorry sir, you need to have an annual pass or a full-coverage ticket to get in.'

The $2 made a huge difference in getting Deuce in, but it just wasn't enough to get him everything he wants in aquarium.

In the REST API world, the power of 2 lies in the difference between error codes 401(Unauthorized) and 403(Forbidden). If your API request receives a 401  response, it may break your heart, but the truth is that the API server is singing to you, 'you’re no good, you’re no good, you’re no good, baby you’re no good'. The credentials you used for the query just won't get you anywhere. You must have both the correct identity and evidence (password, token ,etc.) to prove that you are not an imposter.

If you get a 403 response, the API server actually recognizes your identity, but it cannot grant you permission to perform this particular request. Some systems use 'Role-based access control (RBAC)' to manage system access, including APIs, which means different levels of permissions and privileges based on the user's role.  So, a user who can access a system’s web portal may not necessarily  have access to its APIs. Will you be happier if you receive 403 response ? While receiving a 403 response is not ideal, it is better than receiving a 401 response, which indicates complete lack of access.

An example of 403 response from the REST API request may look like this:

{

    "message": "Role does not have valid permissions to access the API",

    "response": {

        "failureReason": "Your role is not allowed to perform this function. Please contact your System Administrator."

    }

}

We can't say for sure that getting a 403 response means you can't access the API at all. It depends on the implementation. Users can be restricted to different levels of access, such as read-only access, and only have the ability to make GET requests."

Also, don’t assume that you only have permission problem when you receive a 403 . Once the API server determines that  you don’t have permission to execute  this query, it won’t bother to continue validating the rest of code.

If you are working on REST API and receiving a 401 error and it’s not caused by typo, or if you are getting 403 error , you need to contact someone who has admin power to help you get going.

The power of 2 is full of surprises. The number 2 is ubiquitous – it’s present in the difference between 403 and 401 obviously.  But there are other instance of 2 here as well. There’s a pair of people named  “Deuce” with the person in the ticket booth, “Deuce” with the guy behind him and “Deuce”  with the ticket taker. Additionally, the word “deuce” also means 2. And you probably already know that the computer you’re using operates on the base 2 system.

The power of 2 comes in various forms and shapes.

May the power of 2 always be with you -  the power of 2 in 2XX : SUCCESS.

 

 

 

 

 

 

 

1 Reply 1

davidn#
Cisco Employee
Cisco Employee

Once upon a time, in a small village, there was a wise old man who loved to teach his students about the power of numbers. One day, he gathered his students and began to teach them about the power of 2.

He said, "Two is a powerful number. It may seem small, but its power is immense. Let me show you."

He then took out a chessboard and placed a single grain of wheat on the first square, two on the second square, four on the third, and so on, doubling the amount of wheat on each subsequent square until he reached the final square.

The students were amazed as they watched the pile of wheat grow exponentially. When the old man finished, the students counted the total number of grains of wheat, and they were stunned to find that the total number was more than 18 quintillion grains!

The old man smiled and said, "That is the power of 2. With each step, the amount is doubled, and the final result is much greater than we could have imagined. This is why we must never underestimate the power of 2."

From that day on, the students were inspired by the power of 2 and used it to solve many problems in their lives. They learned that even the smallest number can hold great power and that they should never give up, no matter how difficult a problem may seem, for the power of 2 can help them achieve great things.

-The End