简体   繁体   English

Flask-Restful、oauth 和 Salesforce

[英]Flask-Restful, oauth, and Salesforce

I am building out a REST service using Flask-RESTful that will allow users to connect to their salesforce Environment and pull data.我正在使用 Flask-RESTful 构建 REST 服务,该服务将允许用户连接到他们的 Salesforce 环境并提取数据。

Is it possible to secure a restful API with oauth2?!是否可以使用 oauth2 保护一个安静的 API?! I cannot seem to find any documentation this.我似乎找不到任何文档。

The short answer is yes简短的回答是肯定的

Miguel Grinberg talks about securing your REST api (in which he talks about oauth) in his blog post here: Miguel Grinberg 在他的博客文章中谈到了保护 REST api(他在其中谈到了 oauth):

http://blog.miguelgrinberg.com/post/restful-authentication-with-flask http://blog.miguelgrinberg.com/post/restful-authentication-with-flask

and he has a general guide to using oauth with flask here:他在此处提供了在烧瓶中使用 oauth 的一般指南:

http://blog.miguelgrinberg.com/post/oauth-authentication-with-flask http://blog.miguelgrinberg.com/post/oauth-authentication-with-flask

His blog posts answered all of my questions when I was building my flask app and is in general a good resource.他的博文回答了我在构建 Flask 应用程序时的所有问题,并且通常是一个很好的资源。

** The long anser ** ** 长解析器 **

Oauth2 doesn't have any specific functionality that makes it better for authenticating a REST api than any other method of authentication. Oauth2 没有任何特定功能使其比任何其他身份验证方法更适合对 REST api 进行身份验证。 It's just one method of authentication.这只是一种身份验证方法。 The hard part is when a user gets authenticated that they don't have to send their username and password with every request.困难的部分是当用户通过身份验证时,他们不必在每次请求时都发送用户名和密码。 To do this you generate a token for them and store it on the server side and store it in their session on the client side.为此,您为他们生成一个令牌并将其存储在服务器端,并将其存储在客户端的会话中。 Now all you need to do is send the token with any REST requests from the client to authenticate it.现在您需要做的就是发送带有来自客户端的任何 REST 请求的令牌以对其进行身份验证。 This is discussed in the first link (you can find it if you do ctrl-f token)这在第一个链接中进行了讨论(如果您执行 ctrl-f 令牌,您可以找到它)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM