# How to get the token from a Ruby on Rails application?

**URL:** <https://integration.keap.com/t/how-to-get-the-token-from-a-ruby-on-rails-application/66357>\
**Category:** API Q&A\
**Created:** [March 11, 2019, 5:55pm UTC](https://integration.keap.com/t/how-to-get-the-token-from-a-ruby-on-rails-application/66357 "2019-03-11T17:55:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hermes\_Galvis](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@Hermes\_Galvis](https://integration.keap.com/u/Hermes_Galvis)\
**Post date:** [March 11, 2019, 5:55pm UTC](https://integration.keap.com/t/how-to-get-the-token-from-a-ruby-on-rails-application/66357/1 "2019-03-11T17:55:35Z")

</div>

I have an application that is made in Ruby on Rails, we are trying to use the REST API of infusionsoft to automate the creation of users, companies and relate them with events (TAGS).  
We do not want to use the available gem because it is little supported.

To obtain the token, should I implement the OAUTH2 flow? Is there an example? In this case whenever a user enters my application should authorize infusionsoft? Thanks for answering my questions.

How to get the token from a Ruby on Rails application?

---

<div class="post-metadata">

**Author:** ![TomScott](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/tomscott/32/67_2.png) [@TomScott](https://integration.keap.com/u/TomScott)\
**Post date:** [March 12, 2019, 5:42pm UTC](https://integration.keap.com/t/how-to-get-the-token-from-a-ruby-on-rails-application/66357/2 "2019-03-12T17:42:25Z")

</div>

If you are making a single-instance application, you can walk the OAuth flow once yourself to generate a Refresh Token / Access Token, then maintain that in perpetuity to access that application’s data.

If you are making an application for consumers, you’ll need to use the OAuth flow for each user to access their data, and maintain the Refresh Tokens / Access Tokens of each.

[https://developer.infusionsoft.com/getting-started-oauth-keys/](https://developer.infusionsoft.com/getting-started-oauth-keys/)

[https://developer.infusionsoft.com/tutorials/making-oauth-requests-without-user-authorization/](https://developer.infusionsoft.com/tutorials/making-oauth-requests-without-user-authorization/)

---

<div class="post-metadata">

**Author:** ![Hermes\_Galvis](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@Hermes\_Galvis](https://integration.keap.com/u/Hermes_Galvis)\
**Post date:** [March 12, 2019, 6:57pm UTC](https://integration.keap.com/t/how-to-get-the-token-from-a-ruby-on-rails-application/66357/3 "2019-03-12T18:57:23Z")

</div>

[TomScott](https://integration.keap.com/u/TomScott) Yes the applications is a single-intance, this is the client. I implement de flow all in the server side. But i have another question, i find in the documentation the Grant API access. Can I get the initial token and refresh token values in this form, and then continually check if token is expire and refresh it? I think that also save this values.  
Am i in the correct ?

Thanks

---

<div class="post-metadata">

**Author:** ![John\_Borelli](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/john_borelli/32/11880_2.png) [@John\_Borelli](https://integration.keap.com/u/John_Borelli)\
**Post date:** [March 15, 2019, 3:57pm UTC](https://integration.keap.com/t/how-to-get-the-token-from-a-ruby-on-rails-application/66357/4 "2019-03-15T15:57:09Z")

</div>

No matter what language you develop in, the principals are the same, and I would recommend maintaining your access/refresh tokens for 24 hour refresh on a repeated cycle. (see vid for details)

[![](https://us1.discourse-cdn.com/flex019/uploads/infusionsoft1/original/2X/6/636d9b0c40071bb3385c3bbf0995d6c5fd9b1be5.jpeg "Using OAuth2 and Infusionsoft API/REST") ](https://www.youtube.com/watch?v=zjS8tCmnkBs)
