标签: omniauth-twitter

回调重定向不保留会话

我有一个方案,当我使用真正的omniauth时工作得很好,但是当我用黄瓜/水豚的模拟auth运行它时失败了.

在回调中,当我这样做时sign_in @user,它成功创建用户并登录... current_user已设置.但是当我这样做时redirect_to request.env['omniauth.origin'] || '/',在接下来的行动中,current_user现在是零.

我已通过屏幕截图确认/暂停浏览器它不能使用模拟身份验证.firefox和chrome驱动程序中出现相同的错误.

知道为什么会发生这种情况吗?

/features/support/env.rb:

Cucumber::Rails::Database.javascript_strategy = :truncation
Run Code Online (Sandbox Code Playgroud)

场景:

@javascript
Scenario:
    Given I am on the home page
    When I press "Login"
    And I should see "Login with Twitter" in the selector "#login-modal"
    Given Omniauth returns a user with provider "twitter" and uid "1" and nickname "foo"    
    When I login with Twitter
    Then I should be logged in as "foo"
Run Code Online (Sandbox Code Playgroud)

步骤定义:

Given(/^Omniauth returns a user with provider "(.*?)" …
Run Code Online (Sandbox Code Playgroud)

cucumber capybara omniauth omniauth-twitter

46
推荐指数
1
解决办法
570
查看次数

Omniauth-twitter与Rails 5停止工作!OAuth ::未经授权403禁止使用

一切都很好,Omniauth突然停止了工作.我没有进行任何代码更改.

我检查了Twitter应用程序设置:我有回调网址到我的主要生产网址,并且回拨网址已锁定为否.所有密钥都是正确的.

任何的想法?


的OAuth ::未经授权

403禁止

在此输入图像描述

ruby-on-rails devise omniauth ruby-on-rails-5 omniauth-twitter

25
推荐指数
2
解决办法
2412
查看次数

Devise Oauth推特:OAuth ::未经授权禁止403

我正在尝试使用Devise实现Oauth Twitter.
我在twitter上创建了应用程序
我已将回调网址设置为:http:// localhost:3000
我已将此添加到config\initializers\devise.rb

  config.omniauth :twitter, "key", "key secret"
Run Code Online (Sandbox Code Playgroud)

使用Twitter登录会自动出现在此路线:/ users/sign_up /但点击它时我收到此错误

密钥和密钥是正确的

我也尝试删除和创建新的应用程序.

我无法修复它

非常感谢帮助

在此输入图像描述

这里说它需要设置https.所以我按照这个来设置它.但得到同样的错误

ruby-on-rails omniauth omniauth-twitter

4
推荐指数
2
解决办法
2206
查看次数

没有路由匹配 [GET] "/auth/twitter" OmniA

我没有使用设计或其他一些类似的宝石。我对 RoR 很陌生。

这是我的routes.rb

# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html

Rails.application.routes.draw do
  get "about", to: "about#index"

  get "password", to: "passwords#edit", as: :edit_password
  patch "password", to: "passwords#update"

  get "password/reset", to: "password_resets#new"
  post "password/reset", to: "password_resets#create"
  get "password/reset/edit", to: "password_resets#edit"
  patch "password/reset/edit", to: "password_resets#update"
  
  get '/auth/:provider/callback', to: 'sessions#create'

  get "sign_up", to: "registrations#new"
  post "sign_up", to: "registrations#create"

  get "sign_in", to: "sessions#new"
  post "sign_in", to: "sessions#create"

  delete "logout", to: "sessions#destroy"

  root to: "main#index"
end

Run Code Online (Sandbox Code Playgroud)

这是 user.rb

# email:string …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails omniauth-twitter

4
推荐指数
1
解决办法
644
查看次数

验证失败:密码不能为空

我有一个应用程序,基于Rails 4.2,并尝试使用Twitter进行身份验证RailsCasts #241 Simple OmniAuth.
但是有这个问题:Validation failed: Password can't be blank!
我到处搜索答案,但没有找到解决方案!

user.rb

class User < ActiveRecord::Base

    has_secure_password
    validates :password, length: { minimum: 6 }, allow_blank: true
    def self.create_with_omniauth(auth)
        create! do |user|
            user.provider = auth.provider
            user.uid = auth.uid
            user.name = auth.info.name
        end
    end
end
Run Code Online (Sandbox Code Playgroud)

sessions_controller.rb

class SessionsController < ApplicationController
   def login
   end

   def create
       @user = User.find_by_email(params[:email])
       if @user && @user.authenticate(params[:password])
           session[:user_id] = @user.id
           redirect_to root_path
       else
           redirect_to :back
       end
   end

   def create_session
       auth = request.env['omniauth.auth']
       user …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails omniauth ruby-on-rails-4.2 omniauth-twitter

2
推荐指数
2
解决办法
3842
查看次数