如何在 OAuth API 中使用 swagger? [英] How to use swagger with OAuth API?

查看:55
本文介绍了如何在 OAuth API 中使用 swagger?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将 swagger 用作使用 OAuth2 的 API 的文档/测试工具?我在 swagger 网站(或其他任何地方)上看不到任何内容.我见过的每一种用法都使用 API 密钥、HTTP 基础或 cookie.

Is it possible to use swagger as a documentation/testing tool for APIs that use OAuth2? I don't see anything on the swagger site (or anywhere else for that matter). Every usage I've seen uses either an API key, HTTP basic, or cookies.

推荐答案

我一直在沿着相同的路线工作.Swagger 将接受任何标头或 URL 定义的 api 密钥或令牌.向 api 和应用程序添加验证助手是一种标准方法.

I have been working along the same lines. Swagger will accept any header or URL defined api key or token. Adding a validation helper to the api and app is a standard approach.

Oauth 确实需要 HTML 审查和/或登录才能启动握手认证过程.这意味着 swagger api 将需要支持标准登录和范围接受的 Web 界面.将 oauth 变成 swagger 会导致一些逻辑循环,从长远来看,这些循环不容易支持.

Oauth does require a HTML review and or login to start the handshake aouth process. This means that a swagger api will need to support a web interface for a standard login and scope acceptance. Rolling oauth into swagger results in a few logic loops, which long term are not easy to support.

我们正在探索的另一种方法是让 api 处理和存储许多不同 oauth 提供者的访问令牌;GitHub、推特和脸书.这也可能导致登录循环.

A different approach we are exploring is the option to let the api handle and store access tokens for a number of different oauth providers; GitHub, twitter and Facebook. This might result in login loops as well.

这篇关于如何在 OAuth API 中使用 swagger?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆