问题描述
我想从 GMail 获取 oauth 或 xauth 令牌以与 gmail-oauth 一起使用.我正在考虑使用 OmniAuth 但它似乎还不支持 GMail,这意味着使用股票 OmniAuth不可能的.那是对的吗?我错过了什么吗?
I want to get oauth or xauth tokens from GMail to use with gmail-oauth. I'm thinking of using OmniAuth but it seems not to support GMail yet, which means that with stock OmniAuth is impossible. Is that correct? Am I missing something?
推荐答案
Omniauth 支持 OAuth 和 OAuth2,这将两者都允许您对 Google 帐户进行身份验证.
Omniauth has support for both OAuth and OAuth2, which will both allow you to authenticate a google account.
以下是您可以通过 omniauth 使用的所有策略:https://github.com/intridea/omniauth/wiki/List-of-Strategies
Here are all of the strategies you can use via omniauth:https://github.com/intridea/omniauth/wiki/List-of-Strategies
以下是两个 google OAuth gem:
Here are the two google OAuth gems:
根据第一个 gem 的文档:
As per the documentation of the first gem:
将中间件添加到 config/initializers/omniauth.rb 中的 Rails 应用程序:
Add the middleware to a Rails app in config/initializers/omniauth.rb:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google, CONSUMER_KEY, CONSUMER_SECRET
# plus any other strategies you would like to support
end
这是在另外设置主要omniauth gem的基础上完成的.
This is done in addition to setting up the main omniauth gem.
这篇关于是否可以使用 OmniAuth 获取 Gmail oauth 或 xauth 令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!