Hi,
I'm having a bit of a nightmare getting this working, probably something fundamental I'm missing on the Rails end.
When I visit /auth/wordpress_hosted it successfully goes to WordPress and logs in, then returns to Rails, but shows this error: Could not authenticate you from WordpressHosted because "Invalid credentials".
There's a more specific error in the logs Unknown request:
Started GET "/users/auth/wordpress_hosted/callback?code=852b0819f536d44d4c6daa19a648c0c9d42fbae4&state=b79bf1b2824dd58c983263cc9e2e4bd71156b9d6e174a964"
INFO -- omniauth: (wordpress_hosted) Callback phase initiated.
ERROR -- omniauth: (wordpress_hosted) Authentication failure! invalid_credentials: OAuth2::Error, invalid_request: Unknown request
{"error":"invalid_request","error_description":"Unknown request"}
Gems:
devise 3.5.1
omniauth-wordpress_hosted 0.0.2 from git://github.com/jwickard/omniauth-wordpress-oauth2-plugin.git
oauth2 1.0.0
omniauth 1.2.2
omniauth-oauth2 1.3.1
WP:
WordPress 4.2.2
WordPress OAuth Server 3.1.3
Host:
I've tried WordPress on both Tsohost and Pantheon.
devise.rb:
config.omniauth :wordpress_hosted, ENV['OAUTH_ID'], ENV['OAUTH_SECRET'],
strategy_class: OmniAuth::Strategies::WordpressHosted,
client_options: { site: 'http://my-site.com' }
Have also tried putting the keys directly in here as strings.
omniauth_callbacks_controller.rb:
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def wordpress_hosted
@user = User.find_for_wordpress_hosted(request.env["omniauth.auth"], current_user)
if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Wordpress Hosted"
sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
else
session["devise.wordpress_hosted_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
end
user.rb:
:omniauth_providers => [:wordpress_hosted]
..
I tried putting debug lines in and this block doesn't get executed:
def self.find_for_wordpress_hosted(oauth, signed_in_user=nil)
if signed_in_user
return signed_in_user
else
user = User.find_by_uid(oauth['uid'])
if user.nil?
user = User.create!(email: oauth['info']['email'], uid: oauth['uid'], firstname: 'test', lastname: 'test')
end
user
end
end
routes.rb:
devise_for :users, controllers: { omniauth_callbacks: 'omniauth_callbacks' }
The doc says wordpress_oauth2 a few times, I ran into some prior problems with this (passthru error) but changing it to wordpress_hosted got me to the point where everything runs and I get the Unknown request error.
Hi,
I'm having a bit of a nightmare getting this working, probably something fundamental I'm missing on the Rails end.
When I visit
/auth/wordpress_hostedit successfully goes to WordPress and logs in, then returns to Rails, but shows this error:Could not authenticate you from WordpressHosted because "Invalid credentials".There's a more specific error in the logs
Unknown request:Gems:
devise 3.5.1
omniauth-wordpress_hosted 0.0.2 from git://github.com/jwickard/omniauth-wordpress-oauth2-plugin.git
oauth2 1.0.0
omniauth 1.2.2
omniauth-oauth2 1.3.1
WP:
WordPress 4.2.2
WordPress OAuth Server 3.1.3
Host:
I've tried WordPress on both Tsohost and Pantheon.
devise.rb:
Have also tried putting the keys directly in here as strings.
omniauth_callbacks_controller.rb:
user.rb:
..
I tried putting debug lines in and this block doesn't get executed:
routes.rb:
The doc says
wordpress_oauth2a few times, I ran into some prior problems with this (passthru error) but changing it towordpress_hostedgot me to the point where everything runs and I get the Unknown request error.