Rails 6 API Tutorial - Building an Authentication Endpoint p.19

Rails 6 API Tutorial - Building an Authentication Endpoint p.19

Rails Pro

3 года назад

5,171 Просмотров

In this video series we will build a Rails API from scratch. Backend APIs are useful for serving data to frontend applications, mobile apps or other backend services.

✨ Check out the new version of this video series, which has been updated for Rails 7 https://youtu.be/FJiIvFoxqsc

📖 You can also purchase the eBook and code for the new Rails 7 tutorial - https://tomkadwill.gumroad.com/l/rails-api-tutorial

This video covers:
00:00 - Introduction
00:27 - Adding a request spec for authentication
02:29 - Adding an /authenticate route
03:34 - Adding an AuthenticationController with 'create' action
04:45 - Updating the spec to post username and password params
05:49 - Updating the spec to check the response code is :created
06:24 - Adding an expectation to check the response body contains a token
07:15 - Adding 'render :json' to the controller, with token and status
08:00 - Adding a test for the case where user doesn't provide username/password
10:36 - Using required params in the auth controller
12:06 - Adding a rescue_from block to catch ParameterMissing and return error response
14:08 - Adding expectation to check the response body includes missing param message

If you’re new to this series, you may want to start with part 1: https://youtu.be/6KqbPJtA5O8

Тэги:

#GoRails #Traversy_Media #Deanin #Rails_6 #Rails_6_API #Rails_6_API_JWT #Rails_JWT #Rails_authentication #Rails_6_authentication #Rails_API_JWT #Rails_authentication_JWT #Rails_6_authentication_JWT #Rails_6_API_authentication_JWT #Rails_JWT_payload #Rails_JSON_Web_Token #Rails_6_JWT_payload #Rails_6_auth_endpoint #Rails_6_authentication_endpoint #Rails_6_authentication_API #Rails_auth_endpoint #Rails_authentication_endpoint #Rails_auth_API #Rails_authentication_API
Ссылки и html тэги не поддерживаются


Комментарии:

Ahmed Mustafa
Ahmed Mustafa - 02.08.2022 18:04

Thanks man, this series helped me a lot ❤

Ответить
Vibhanshu Jain
Vibhanshu Jain - 10.02.2022 13:46

Hi
Can you add the video to test external API , i.e API hosted on some server and we dont have code for the same

Ответить
Leandre
Leandre - 03.01.2022 15:52

request_body doesn't work for me. Will using request.body work?

Ответить
Balabala
Balabala - 25.03.2021 07:17

Hi, Why my error say:
+"error" => "param is missing or the value is empty: username\nDid you mean? password\n controller\n action",

I can't use this,
expect(response_body).to eq({
'error' => 'param is missing or the value is empty: username'
})

Ответить
Jeff Carley
Jeff Carley - 27.12.2020 23:07

Thank you for doing these via TDD. So refreshing. I wish more people would include testing with their video streams.

Ответить
Prasanga Thapaliya
Prasanga Thapaliya - 06.12.2020 06:45

Where is next part ? Haven't you uploaded it? I'm enjoying this series.

Ответить
liondancer
liondancer - 29.11.2020 11:25

Amazing work! Please keep this up!

Ответить