Query String Parameter:
- Appears after the question mark (?) in a URL.
- Used to filter, sort, or alter the response from an API without changing the resource.
- Example:
http://example.com/api/stuff?sort=asc&limit=10
Path Parameter:
- Part of the URL path itself and used to identify specific resources.
- Placed within the URL structure.
- Example:
http://example.com/api/stuff/123
- Domain:
http://our-site.com
- Version:
v3
- Model name:
stuff
- ID:
things
API URL:
http://our-site.com/v3/stuff/things
We have created a dynamic API with an “interface”. Describe how that interface works to a non-technical friend.
Imagine our API is like a waiter at a restaurant. When you go to a restaurant, you tell the waiter what you want, and they bring it to you. Similarly, the API interface takes requests from users, figures out what data or actions they need, and brings back the right information or performs the requested action.
Basic Authentication:
- Intercept incoming requests.
- Check for the
Authorization
header. - Decode the header to extract the username and password.
- Validate these credentials against your user database.
- Allow the request to proceed if valid; otherwise, respond with an error.
Bearer Authentication:
- Check for a bearer token in the
Authorization
header. - Extract and verify the token.
- Validate the token against your authentication service.
- Allow the request to proceed if valid; otherwise, respond with an error.
-
Client Registration:
- Register your app with the OAuth provider to get a client ID and secret.
-
Authorization Request:
- Redirect the user to the OAuth provider’s authorization server.
-
User Authorization:
- User logs in and grants permission to your app.
-
Authorization Code:
- OAuth provider redirects back with an authorization code.
-
Token Exchange:
- Exchange the code for an access token using the client ID and secret.
-
Access Token:
- Receive an access token to make authenticated requests.
Think of Role Based Access Control (RBAC) like a hotel key system. Each person gets a key card that lets them into certain rooms based on their role.
- Guest: Can access their own room and common areas.
- Housekeeping: Can access all guest rooms for cleaning.
- Manager: Can access all areas.
In software, users have roles with specific permissions, ensuring they can only access what they're supposed to. This keeps everything secure and organized.