Questions About Consuming Your Own API with OAuth

拥有回忆 提交于 2019-12-02 14:08:39

I have come across the same issue and solved it like this.

1 For third party apps, using my API, they have to authenticate via OAuth on all requests.

2 For my own third party clients, (mobile, AIR etc) - they use OAuth, with the difference that I allow these to send username and password directly in the authorization step (so I can make a native login dialogue). This is provided that your API is over SSL/HTTPS.

3 For my web application, I use cookie authentication to access the APIs. I.e after having logged in, the user could simply call API:urls and get JSON/XML back. Nice for quick exploring the APIs also (although a real API Console like APIGee does a better job there).

I would say you're overcomplicating it a little. If your code is seperated properly, you can easily build a thin REST layer over your application's service layer, while having your application's controllers be a thin layer over your service layer as well.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!