I provide a set of public web APIs for third party apps (clients) to use. I want to track how these clients use my APIs, so I need to generate tokens for these clients. As the same time, I need to authenticate real users, and different users can see different representations of the same resources. I know OAuth2 can solve my problem, but it is complicated. I prefer using HTTPs + basic authentication for both the user and the application, so I will use different properties in the HTTP header for client and real user. Is it appropriate way?
相关问题
- Angular RxJS mergeMap types
- Design RESTful service with multiple ids
- Axios OPTIONS instead of POST Request. Express Res
- Plain (non-HTML) error pages in REST api
- java client program to send digest authentication
相关文章
- C#使用http访问网络,有办法用指定网卡访问网络嘛?
- Using JAX-WS 2.2.5 client with JDK/JRE 1.5
- Is a unicode user agent legal inside an HTTP heade
- Cannot use org.jvnet.jax-ws-commons.jaxws-maven-pl
- Got ActiveRecord::AssociationTypeMismatch on model
- Multiple parameters in AngularJS $resource GET
- git: retry if http request failed
- How to create base64Binary data?
Generally speaking, Basic Authentication does not do the job because it requires credentials (username/password) for all the requests and this is not what you want.
Firstly let's analyze your requirements:
So we could summarize the ideal workflow as:
Based on above workflow, end user have only input 1 time username/password, so Basic Authentication does not fulfill your requirement.
Actually, your requirement is Token Based Authentication (for sure you need token expiration mechanism): The 3rd party only gets end users' authorization token rather than credentials.
To do this, without OAuth, you need implement token generation, validation and expiration mechanism.
And for sure you could put those tokens either in HTTP header or URL which depends on your preference or design philosophy.
Hope this help!