How to access WP REST API via OAuth by using Rails - ruby-on-rails

I can't figure out how to access Wordpress via REST API with OAuth.
My App is made by Ruby on Rails. So I'd like to use RoR 5.1.
My objective is to get all post from the api.
As far as I check, no appropriate gem is there.
Anyone help please.

In Rails the common gem to deal with OAuth is OmniAuth.
1) If you did your authentication system based on Devise then you have an easy way to add OAuth to your app.
Here a good example to connect to Facebook API with Devise:
https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
Here the gem to connect with WordPress:
https://github.com/jwickard/omniauth-wordpress-oauth2-plugin
2) If you didn't your authentication system with Devise then check the OmniAuth documentation to add it to your app:
https://github.com/omniauth/omniauth
And of course you will use the WordPress gem to add the strategy as well.

Related

How to create a user authentication using rails as backend and ember as frontend

I'm working on eCommerce for my internship project. But I don't know how to create the user authentication using rails and ember
First I assume the following things:
You are using ember to develop your frontend and will consume APIs from the backend.
You are using rails to create the necessary API.
If you want to authenticate users before using your API, check out the doorkeeper and devise gem. Devise takes care of things like storing your user details in the database, resetting the password, etc. The Doorkeeper gem is used to provide authentication and authorization to APIs.
Doorkeeper Link: https://github.com/doorkeeper-gem/doorkeeper
Devise Link: https://github.com/heartcombo/devise

SSO integration using Rails for WordPress

I am building Rails Application which re-directs users to a WordPress Site. All exisiting users are in Rails Database.Now I want to use SSO from Rails App to Wordpress.
I came across this solution but
I am using custom authentication method instead of devise gem as called out in the solution.
Is there any other alternate methods to solve this?

Rails API using Devise for authenticaion

I set up a rails API and I am using devise for the user auth and the front end is all done in Angular. What is the best way to manage state between calls when using Devise with just an API?
Here are some open-source projects that may help you:
https://github.com/lynndylanhurley/devise_token_auth
https://github.com/cloudspace/angular_devise

Which one HTTP gem should I use

I want to create microservice (probably as a gem) and It will be REST client to call external API. I'm new at rails and I am investigating which gem I should use. I checked https://www.ruby-toolbox.com/categories/http_clients to verfify most popular gems and I'm reading about them on google. I thought to write a question and ask you about your favourite one. I will call JSON API using token auth. Which one I should use? Thanks for all answers.
The 'Devise' gem is the most popular gem for Rails with authentication.
These links here will provide you with more details on how to configure Devise to work with a JSON API using token auth:
http://abhionrails.com/ruby/rails/devise/token/based/authentication/api/json/2013/09/01/Devise-with-token-based-authentication-for-API/
Is this Rails JSON authentication API (using Devise) secure?

Rails 3 - Use only OpenID authentication

I want to add authentication to my Ruby on Rails 3 app, but I only need users to be able to authenticate using their Google accounts, because I'm making it a hosted app for the Chrome Webstore, so I think OpenID would work well for this. I want to have some custom fields in the user database to store user-specific data. What should I use for this? I want users to be able to sign up only with OpenID.
Thanks.
You should try omniauth gem, it uses not only Google OpenID. Omniauth takes user's data from provider and pass to your application which is you can amplify
I've been using authlogic and authlogic-oid add-on to handle this.
You could try the devise_openid_authenticatable gem. I haven't used it myself but it looks like it would do what you want using the Devise authentication gem, which is what I use on all of my Rails projects.

Resources