Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 1.65 KB

README.md

File metadata and controls

52 lines (36 loc) · 1.65 KB

GotSurf Service Heroku

Prerequisites

First will have to create a new entry in credentials file to store the Telegram access key, that will be used later to seed the Bot user information

$ EDITOR="vim" rails credentials:edit

Add the following lines

telegram_bot:
 access_key: <telegram_bot_access_key>

Seed the database using rake:seed command

$ rake db:create db:migrate db:seed

This process will create a user with an made up email and using the previous credentials telegram_bot[:access_key]

{email: "bot@gotsurf.com",password:Rails.application.credentials.telegram_bot[:access_key]}

Once done that, it's time to generate a JWT Token using a class method in JsonWebToken class, so run rails console an type the following command:

irb(main):004:0> JsonWebToken.encode({sub:1})
=> "eyJhbGcisdfgsdJIUzI1NiJ9.eyJzdWIiOjEsdfsdsdszNjAxOTAzOH0.LwcpJ-3XW_pxocfdgfgdfg8oio7Kl0wuD3SYa60xcM"

Use this token on your Bot application to make the call towards the service.

response = self.class.get('/spots', headers: {"Authorization" => "Bearer #{ENV[:JWT_USER_TOKEN.to_s]}"})

Usage

Built With

Authors

Eduard Garcia Castelló - Linkedin - Twitter

License

This project is licensed under the MIT License - see the LICENSE.md file for details