SlideShare a Scribd company logo
1 of 39
Download to read offline
How to
Implement
SSO using
OAuth in
Golang
Application
www.bacancytechnology.com
Introduction
You all have definitely come across the Login
page where the website or application provides
you the option of Login with Google or
Facebook. Doesn’t that reduce your efforts of
registering your account for the respective
website? Almost all the websites have a
mandatory criterion of login before accessing
the information or visiting other web pages.
Imagine the scenario of signing up on these
websites and remembering their credentials.
Thus, social login saves your time and effort
easing your process to surf various websites.


Now, the question is do you know to implement
single sign-on (SSO) using OAuth in your golang
app? If no, then don’t worry here is the tutorial:
How to implement SSO using OAuth in golang
application; if yes, then let me know any other
better way for the same (constructive feedbacks
always help). We will see a few theoretical parts
regarding our topic and then get started with
the coding part.
We also have a video tutorial on the same
topic. The entire tutorial is covered in the
video form and is attached in the below
section.
What is Single
Sign-On
(SSO)?
One Time Log In.


Single Sign-On (SSO) provides users the
opportunity to log in using a single user ID
and password to related yet independent
platforms. In layman terms, you can sign in
to your Google account and use the same
account to log in or sign up in various other
software applications.
Video
Tutorial:
Implementing
SSO using
OAuth in
Golang
Application
If you are someone who grasps more from
video tutorials then here is a
comprehensive video tutorial on
implementing SSO using OAuth in Golang
Application from our developer.


The video will show you each and
everything with a few helpful insights that
you need to know. It will cover registering
the application to the Google Console,
Backend, and Frontend coding part.
Want to develop a Scalable and Secure
Golang project from scratch?


We’d never compromise the project quality,
and that’s the reason why our clients love
us!


Hire Golang Developers
Register
Application to
Google
Console
Dashboard
The first step would be registering our
golang application to Google Console
Dashboard. For that Select Credentials
under APIs and Services section. If you
want you can choose the existing project,
here we will create a New Project as shown
in the below image.
Fill in the details as asked. Here my project
name is Testing-SSO-Golang
Once done with creating the project make
sure you have selected the project, here,
Testing-SSO-Golang.
Configure
OAuth
Consent
Screen
Now, it’s time to configure the OAuth
Consent Screen. For that, we will need to
Add Application Information,


OAuth Consent Screen
Scopes
Test Users
Here is the Summary of all three steps.
Create
Credentials
Create OAuth Client ID
Now, moving towards creating credentials
.
Download the JSON file after the OAuth
client is created.
So, this was about how to register your
golang app and create an OAuth client. Now,
it’s time to do some code.
.
Backend
Initial Set-Up
Run the below command to create initiate
the go.mod file.


go mod init golang-sso
This will be our project structure-


Create main.go and use the below-
mentioned code.
package main
import (
"golang-sso/controllers"
"net/http"
)
func main(){
fs := http.FileServer(http.Dir("public"))
http.Handle("/",fs)
http.HandleFunc("/signin",controllers.Signi
n)
http.HandleFunc("/callback",controllers.Cal
lback)
http.ListenAndServe(":3000",nil)
}


// main.go
The /signin route in this line of code
http.HandleFunc(“/signin”,controllers.Si
gnin) is for handling URL generation
and later after sign in redirecting to that
URL.
The /callback route in this line of code
http.HandleFunc(“/callback”,controllers
.Callback) is for getting code and state of
the current user from Google console.
Explanation
Controllers
package
package controllers
import (
"fmt"
"log"
"net/http"
"os"
"github.com/joho/godotenv"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
)
var ssogolang *oauth2.Config
var RandomString = "random-string"
func init(){
err := godotenv.Load("./.env")
if err != nil {
Now, create two files: signin.go and
callback.go within the folder controllers.


// signin.go
p log.Fatal("Error loading .env file")
}
ssogolang = &oauth2.Config{
RedirectURL:os.Getenv("REDIRECT_URL"),
ClientID:os.Getenv("CLIENT_ID"),
ClientSecret:os.Getenv("CLIENT_SECRET"),
Scopes:
[]string{"https://www.googleapis.com/auth/
userinfo.email"},
Endpoint: google.Endpoint,
}
}
func Signin(w http.ResponseWriter, r
*http.Request){
url
:=ssogolang.AuthCodeURL(RandomString)
fmt.Println(url)
http.Redirect(w,r,url,http.StatusTemporary
Redirect)
}
ssogolang = &oauth2.Config{…} is to
configure our backend code with our
console app using the credentials we got
from there.
Further, we will enter the scope needed in
the configuration. Here, we want the email
id of the user so we’ve used
[]string{“https://www.googleapis.com/auth/
userinfo.email”}.
This will our generated URL
Explanation
Generate the random string to uniquely
identify user from the user state and then pass
it to the AuthcodeUrl function from the OAuth
package that generates URL with the required
configuration
package controllers
import (
"context"
"errors"
"fmt"
"io/ioutil"
"log"
"net/http"
)
func Callback(w http.ResponseWriter, r
*http.Request){
state :=r.FormValue("state")
code := r.FormValue("code")
data,err:=getUserData(state,code)
if err!=nil{
log.Fatal("error getting user data")
}
// callback.go
fmt.Fprintf(w,"Data : %s",data)
}
func getUserData(state,code string)([]byte,error){
if state != RandomString{
return nil,errors.New("invalid user state")
}
token,err:=ssogolang.Exchange(context.Backgroun
d(),code)
if err!=nil{
return nil,err
}
response,err
:=http.Get("https://www.googleapis.com/oauth2/v2
/userinfo?access_token=" + token.AccessToken)
if err!=nil{
return nil,err
}
defer response.Body.Close()
data,err:=ioutil.ReadAll(response.Body)
if err!=nil{
return nil,err
}
return data,nil
}
state :=r.FormValue(“state”) ,code :=
r.FormValue(“code”) This line of code will
fetch the user state and code from Google
console.
Further, check the user state to uniquely
identify the user with the help of if state !=
RandomString
Exchange the code for a token using the
Exchange(…) function, a part of OAuth flow
using the OAuth library.
Now get the user data from Google APIs
using the token we got using this line of
code response,err
:=http.Get(“https://www.googleapis.com/o
auth2/v2/userinfo?access_token=” +
token.AccessToken)
fExplanation
Front-end Set-
Up
So far we have covered the backend part for
implementing SSO using OAuth in our
golang app. Now, it’s time to write some
front-end code.


Open index.html and use the below code for
the user interface. You can surely change
the UI according to your wish.


// index.html
<div>
<form action="/action_page.php">
<div class="row">
<h2 style="text-align:center">
Login with Social Media or Manually
</h2>
<div class="vl">
<span class="vl-innertext">or</span>
</div>
<div class="col">
<a href="#" class="fb btn">
<i class="fa fa-facebook fa-fw"></i> Login
with Facebook
</a>
<a href="#" class="twitter btn">
<i class="fa fa-twitter fa-fw"></i> Login
with Twitter
</a>
<a href="/signin" class="google btn">
<i class="fa fa-google fa-fw"></i> Login
with Google+
</a>
</div>
<div class="col">
<div class="hide-md-lg">
<p>Or sign in manually:</p>
</div>
<input type="text"
name="username"
placeholder="Username"
required
>
<input type="password"
name="password"
placeholder="Password"
required
>
<input type="submit" value="Login">
</div>
</div>
</form>
<div class="bottom-container">
<div class="row">
<div class="col">
<a href="#" style="color:white"
class="btn">Sign up</a>
</div>
<div class="col">
<a href="#" style="color:white"
class="btn">Forgot password?</a>
</div>
</div>
</div>
</div>
<a href=”/signin ”>
will redirect you to the sign-in route when
you click the button.
Github
Repository
If you want to clone the project and play
around with the code then here’s the source
code: sso-using-oauth-demo
Conclusion
So, this was about how to implement SSO
using OAuth in the Golang application. I
hope the purpose of this step-by-step
guideline has been served as expected. For
more such Golang tutorials with github
sources feel free to visit the Golang tutorials
page.


Bacancy has skilled developers with
fundamental and advanced knowledge. Are
you looking for a helping hand for your
golang project? If yes, then without a
second thought, contact our Golang
developers
Thank You
www.bacancytechnology.com

More Related Content

What's hot

Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in Sandeep Tol
 
Html 5-tables-forms-frames (1)
Html 5-tables-forms-frames (1)Html 5-tables-forms-frames (1)
Html 5-tables-forms-frames (1)club23
 
Tricentis Tosca - Email Notification of Execution Reports
Tricentis Tosca - Email Notification of Execution ReportsTricentis Tosca - Email Notification of Execution Reports
Tricentis Tosca - Email Notification of Execution ReportsBilal Ahmed
 
Html 5 New Features
Html 5 New FeaturesHtml 5 New Features
Html 5 New FeaturesAta Ebrahimi
 
Html, CSS & Web Designing
Html, CSS & Web DesigningHtml, CSS & Web Designing
Html, CSS & Web DesigningLeslie Steele
 
Postman Collection Format v2.0 (pre-draft)
Postman Collection Format v2.0 (pre-draft)Postman Collection Format v2.0 (pre-draft)
Postman Collection Format v2.0 (pre-draft)Postman
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web APIhabib_786
 
HTML & CSS: Chapter 06
HTML & CSS: Chapter 06HTML & CSS: Chapter 06
HTML & CSS: Chapter 06Steve Guinan
 
CSS3 2D/3D transform
CSS3 2D/3D transformCSS3 2D/3D transform
CSS3 2D/3D transformKenny Lee
 
Http request&response by Vignesh 15 MAR 2014
Http request&response by Vignesh 15 MAR 2014Http request&response by Vignesh 15 MAR 2014
Http request&response by Vignesh 15 MAR 2014Navaneethan Naveen
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to JavascriptSeble Nigussie
 
L'API Collector dans tous ses états
L'API Collector dans tous ses étatsL'API Collector dans tous ses états
L'API Collector dans tous ses étatsJosé Paumard
 

What's hot (20)

Javascript
JavascriptJavascript
Javascript
 
Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in
 
Html 5-tables-forms-frames (1)
Html 5-tables-forms-frames (1)Html 5-tables-forms-frames (1)
Html 5-tables-forms-frames (1)
 
Tricentis Tosca - Email Notification of Execution Reports
Tricentis Tosca - Email Notification of Execution ReportsTricentis Tosca - Email Notification of Execution Reports
Tricentis Tosca - Email Notification of Execution Reports
 
Html 5 New Features
Html 5 New FeaturesHtml 5 New Features
Html 5 New Features
 
Bootstrap 5 ppt
Bootstrap 5 pptBootstrap 5 ppt
Bootstrap 5 ppt
 
HTML Tables
HTML TablesHTML Tables
HTML Tables
 
Rest API
Rest APIRest API
Rest API
 
Html, CSS & Web Designing
Html, CSS & Web DesigningHtml, CSS & Web Designing
Html, CSS & Web Designing
 
Postman Collection Format v2.0 (pre-draft)
Postman Collection Format v2.0 (pre-draft)Postman Collection Format v2.0 (pre-draft)
Postman Collection Format v2.0 (pre-draft)
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
 
HTML 5 Canvas & SVG
HTML 5 Canvas & SVGHTML 5 Canvas & SVG
HTML 5 Canvas & SVG
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
HTML & CSS: Chapter 06
HTML & CSS: Chapter 06HTML & CSS: Chapter 06
HTML & CSS: Chapter 06
 
CSS3 2D/3D transform
CSS3 2D/3D transformCSS3 2D/3D transform
CSS3 2D/3D transform
 
Http request&response by Vignesh 15 MAR 2014
Http request&response by Vignesh 15 MAR 2014Http request&response by Vignesh 15 MAR 2014
Http request&response by Vignesh 15 MAR 2014
 
CSS Selectors
CSS SelectorsCSS Selectors
CSS Selectors
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
L'API Collector dans tous ses états
L'API Collector dans tous ses étatsL'API Collector dans tous ses états
L'API Collector dans tous ses états
 
CSS
CSS CSS
CSS
 

Similar to How to implement sso using o auth in golang application

Angular 11 google social login or sign in tutorial using angularx social-login
Angular 11 google social login or sign in tutorial using angularx social-loginAngular 11 google social login or sign in tutorial using angularx social-login
Angular 11 google social login or sign in tutorial using angularx social-loginKaty Slemon
 
How to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdfHow to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdfKaty Slemon
 
How to Implement Token Authentication Using the Django REST Framework
How to Implement Token Authentication Using the Django REST FrameworkHow to Implement Token Authentication Using the Django REST Framework
How to Implement Token Authentication Using the Django REST FrameworkKaty Slemon
 
How to build twitter bot using golang from scratch
How to build twitter bot using golang from scratchHow to build twitter bot using golang from scratch
How to build twitter bot using golang from scratchKaty Slemon
 
Using HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in JavaUsing HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in JavaSandeep Tol
 
Magento Imgine eCommerce Conference February 2011: Mashup of Magento and Sale...
Magento Imgine eCommerce Conference February 2011: Mashup of Magento and Sale...Magento Imgine eCommerce Conference February 2011: Mashup of Magento and Sale...
Magento Imgine eCommerce Conference February 2011: Mashup of Magento and Sale...varien
 
Google Wave API: Now and Beyond
Google Wave API: Now and BeyondGoogle Wave API: Now and Beyond
Google Wave API: Now and BeyondMarakana Inc.
 
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on AndroidMobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on AndroidAlberto Ruibal
 
Hands on SPA development
Hands on SPA developmentHands on SPA development
Hands on SPA developmentShawn Constance
 
How to Validate Form With Flutter BLoC.pptx
How to Validate Form With Flutter BLoC.pptxHow to Validate Form With Flutter BLoC.pptx
How to Validate Form With Flutter BLoC.pptxBOSC Tech Labs
 
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIsExploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIswesley chun
 
ChromeとAndroidの過去・現在・未来
ChromeとAndroidの過去・現在・未来ChromeとAndroidの過去・現在・未来
ChromeとAndroidの過去・現在・未来Shinobu Okano
 
How to create a real time chat application using socket.io, golang, and vue js-
How to create a real time chat application using socket.io, golang, and vue js-How to create a real time chat application using socket.io, golang, and vue js-
How to create a real time chat application using socket.io, golang, and vue js-Katy Slemon
 
A Detailed Guide to Securing React applications with Keycloak - WalkingTree ...
A Detailed Guide to Securing React applications with Keycloak  - WalkingTree ...A Detailed Guide to Securing React applications with Keycloak  - WalkingTree ...
A Detailed Guide to Securing React applications with Keycloak - WalkingTree ...Ganesh Kumar
 
The Glass Class - Tutorial 2 - Mirror API
The Glass Class - Tutorial 2 - Mirror APIThe Glass Class - Tutorial 2 - Mirror API
The Glass Class - Tutorial 2 - Mirror APIGun Lee
 
M365 global developer bootcamp 2019 PA
M365 global developer bootcamp 2019  PAM365 global developer bootcamp 2019  PA
M365 global developer bootcamp 2019 PAThomas Daly
 
Google external login setup in ASP (1).pdf
Google external login setup in ASP  (1).pdfGoogle external login setup in ASP  (1).pdf
Google external login setup in ASP (1).pdffindandsolve .com
 

Similar to How to implement sso using o auth in golang application (20)

Angular 11 google social login or sign in tutorial using angularx social-login
Angular 11 google social login or sign in tutorial using angularx social-loginAngular 11 google social login or sign in tutorial using angularx social-login
Angular 11 google social login or sign in tutorial using angularx social-login
 
How to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdfHow to Develop Slack Bot Using Golang.pdf
How to Develop Slack Bot Using Golang.pdf
 
How to Implement Token Authentication Using the Django REST Framework
How to Implement Token Authentication Using the Django REST FrameworkHow to Implement Token Authentication Using the Django REST Framework
How to Implement Token Authentication Using the Django REST Framework
 
How to build twitter bot using golang from scratch
How to build twitter bot using golang from scratchHow to build twitter bot using golang from scratch
How to build twitter bot using golang from scratch
 
Using HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in JavaUsing HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in Java
 
Magento Imgine eCommerce Conference February 2011: Mashup of Magento and Sale...
Magento Imgine eCommerce Conference February 2011: Mashup of Magento and Sale...Magento Imgine eCommerce Conference February 2011: Mashup of Magento and Sale...
Magento Imgine eCommerce Conference February 2011: Mashup of Magento and Sale...
 
Introduction to python scrapping
Introduction to python scrappingIntroduction to python scrapping
Introduction to python scrapping
 
Building a Slack Bot Workshop @ Nearsoft OctoberTalks 2017
Building a Slack Bot Workshop @ Nearsoft OctoberTalks 2017Building a Slack Bot Workshop @ Nearsoft OctoberTalks 2017
Building a Slack Bot Workshop @ Nearsoft OctoberTalks 2017
 
Google Wave API: Now and Beyond
Google Wave API: Now and BeyondGoogle Wave API: Now and Beyond
Google Wave API: Now and Beyond
 
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on AndroidMobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
 
Hands on SPA development
Hands on SPA developmentHands on SPA development
Hands on SPA development
 
How to Validate Form With Flutter BLoC.pptx
How to Validate Form With Flutter BLoC.pptxHow to Validate Form With Flutter BLoC.pptx
How to Validate Form With Flutter BLoC.pptx
 
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIsExploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
 
ChromeとAndroidの過去・現在・未来
ChromeとAndroidの過去・現在・未来ChromeとAndroidの過去・現在・未来
ChromeとAndroidの過去・現在・未来
 
How to create a real time chat application using socket.io, golang, and vue js-
How to create a real time chat application using socket.io, golang, and vue js-How to create a real time chat application using socket.io, golang, and vue js-
How to create a real time chat application using socket.io, golang, and vue js-
 
A Detailed Guide to Securing React applications with Keycloak - WalkingTree ...
A Detailed Guide to Securing React applications with Keycloak  - WalkingTree ...A Detailed Guide to Securing React applications with Keycloak  - WalkingTree ...
A Detailed Guide to Securing React applications with Keycloak - WalkingTree ...
 
The Glass Class - Tutorial 2 - Mirror API
The Glass Class - Tutorial 2 - Mirror APIThe Glass Class - Tutorial 2 - Mirror API
The Glass Class - Tutorial 2 - Mirror API
 
How to implement Google One Tap Login in Reactjs?
How to implement Google One Tap Login in Reactjs?How to implement Google One Tap Login in Reactjs?
How to implement Google One Tap Login in Reactjs?
 
M365 global developer bootcamp 2019 PA
M365 global developer bootcamp 2019  PAM365 global developer bootcamp 2019  PA
M365 global developer bootcamp 2019 PA
 
Google external login setup in ASP (1).pdf
Google external login setup in ASP  (1).pdfGoogle external login setup in ASP  (1).pdf
Google external login setup in ASP (1).pdf
 

More from Katy Slemon

React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfReact Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfKaty Slemon
 
Data Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdfData Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdfKaty Slemon
 
How Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdfHow Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdfKaty Slemon
 
What’s New in Flutter 3.pdf
What’s New in Flutter 3.pdfWhat’s New in Flutter 3.pdf
What’s New in Flutter 3.pdfKaty Slemon
 
Why Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdfWhy Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdfKaty Slemon
 
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfHow Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfKaty Slemon
 
How to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdfHow to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdfKaty Slemon
 
How to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdfHow to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdfKaty Slemon
 
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdfSure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdfKaty Slemon
 
IoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdfIoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdfKaty Slemon
 
Understanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfUnderstanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfKaty Slemon
 
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdfThe Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdfKaty Slemon
 
New Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdfNew Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdfKaty Slemon
 
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdfHow to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdfKaty Slemon
 
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdfChoose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdfKaty Slemon
 
Flutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdfFlutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdfKaty Slemon
 
Angular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdfAngular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdfKaty Slemon
 
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdfHow to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdfKaty Slemon
 
Ruby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdfRuby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdfKaty Slemon
 
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdfUncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdfKaty Slemon
 

More from Katy Slemon (20)

React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfReact Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
 
Data Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdfData Science Use Cases in Retail & Healthcare Industries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdf
 
How Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdfHow Much Does It Cost To Hire Golang Developer.pdf
How Much Does It Cost To Hire Golang Developer.pdf
 
What’s New in Flutter 3.pdf
What’s New in Flutter 3.pdfWhat’s New in Flutter 3.pdf
What’s New in Flutter 3.pdf
 
Why Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdfWhy Use Ruby On Rails.pdf
Why Use Ruby On Rails.pdf
 
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdfHow Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
 
How to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdfHow to Implement Middleware Pipeline in VueJS.pdf
How to Implement Middleware Pipeline in VueJS.pdf
 
How to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdfHow to Build Laravel Package Using Composer.pdf
How to Build Laravel Package Using Composer.pdf
 
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdfSure Shot Ways To Improve And Scale Your Node js Performance.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
 
IoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdfIoT Based Battery Management System in Electric Vehicles.pdf
IoT Based Battery Management System in Electric Vehicles.pdf
 
Understanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfUnderstanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdf
 
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdfThe Ultimate Guide to Laravel Performance Optimization in 2022.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
 
New Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdfNew Features in iOS 15 and Swift 5.5.pdf
New Features in iOS 15 and Swift 5.5.pdf
 
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdfHow to Hire & Manage Dedicated Team For Your Next Product Development.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
 
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdfChoose the Right Battery Management System for Lithium Ion Batteries.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
 
Flutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdfFlutter Performance Tuning Best Practices From the Pros.pdf
Flutter Performance Tuning Best Practices From the Pros.pdf
 
Angular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdfAngular Universal How to Build Angular SEO Friendly App.pdf
Angular Universal How to Build Angular SEO Friendly App.pdf
 
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdfHow to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
 
Ruby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdfRuby On Rails Performance Tuning Guide.pdf
Ruby On Rails Performance Tuning Guide.pdf
 
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdfUncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
Uncovering 04 Main Types and Benefits of Salesforce ISV Partnerships.pdf
 

Recently uploaded

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 

How to implement sso using o auth in golang application

  • 1. How to Implement SSO using OAuth in Golang Application www.bacancytechnology.com
  • 3. You all have definitely come across the Login page where the website or application provides you the option of Login with Google or Facebook. Doesn’t that reduce your efforts of registering your account for the respective website? Almost all the websites have a mandatory criterion of login before accessing the information or visiting other web pages. Imagine the scenario of signing up on these websites and remembering their credentials. Thus, social login saves your time and effort easing your process to surf various websites. Now, the question is do you know to implement single sign-on (SSO) using OAuth in your golang app? If no, then don’t worry here is the tutorial: How to implement SSO using OAuth in golang application; if yes, then let me know any other better way for the same (constructive feedbacks always help). We will see a few theoretical parts regarding our topic and then get started with the coding part.
  • 4. We also have a video tutorial on the same topic. The entire tutorial is covered in the video form and is attached in the below section.
  • 6. One Time Log In. Single Sign-On (SSO) provides users the opportunity to log in using a single user ID and password to related yet independent platforms. In layman terms, you can sign in to your Google account and use the same account to log in or sign up in various other software applications.
  • 8. If you are someone who grasps more from video tutorials then here is a comprehensive video tutorial on implementing SSO using OAuth in Golang Application from our developer. The video will show you each and everything with a few helpful insights that you need to know. It will cover registering the application to the Google Console, Backend, and Frontend coding part.
  • 9. Want to develop a Scalable and Secure Golang project from scratch? We’d never compromise the project quality, and that’s the reason why our clients love us! Hire Golang Developers
  • 11. The first step would be registering our golang application to Google Console Dashboard. For that Select Credentials under APIs and Services section. If you want you can choose the existing project, here we will create a New Project as shown in the below image. Fill in the details as asked. Here my project name is Testing-SSO-Golang
  • 12. Once done with creating the project make sure you have selected the project, here, Testing-SSO-Golang.
  • 14. Now, it’s time to configure the OAuth Consent Screen. For that, we will need to Add Application Information, OAuth Consent Screen Scopes
  • 15. Test Users Here is the Summary of all three steps.
  • 17. Create OAuth Client ID Now, moving towards creating credentials . Download the JSON file after the OAuth client is created.
  • 18. So, this was about how to register your golang app and create an OAuth client. Now, it’s time to do some code. .
  • 20. Run the below command to create initiate the go.mod file. go mod init golang-sso This will be our project structure- Create main.go and use the below- mentioned code.
  • 21. package main import ( "golang-sso/controllers" "net/http" ) func main(){ fs := http.FileServer(http.Dir("public")) http.Handle("/",fs) http.HandleFunc("/signin",controllers.Signi n) http.HandleFunc("/callback",controllers.Cal lback) http.ListenAndServe(":3000",nil) } // main.go
  • 22. The /signin route in this line of code http.HandleFunc(“/signin”,controllers.Si gnin) is for handling URL generation and later after sign in redirecting to that URL. The /callback route in this line of code http.HandleFunc(“/callback”,controllers .Callback) is for getting code and state of the current user from Google console. Explanation
  • 24. package controllers import ( "fmt" "log" "net/http" "os" "github.com/joho/godotenv" "golang.org/x/oauth2" "golang.org/x/oauth2/google" ) var ssogolang *oauth2.Config var RandomString = "random-string" func init(){ err := godotenv.Load("./.env") if err != nil { Now, create two files: signin.go and callback.go within the folder controllers. // signin.go
  • 25. p log.Fatal("Error loading .env file") } ssogolang = &oauth2.Config{ RedirectURL:os.Getenv("REDIRECT_URL"), ClientID:os.Getenv("CLIENT_ID"), ClientSecret:os.Getenv("CLIENT_SECRET"), Scopes: []string{"https://www.googleapis.com/auth/ userinfo.email"}, Endpoint: google.Endpoint, } } func Signin(w http.ResponseWriter, r *http.Request){ url :=ssogolang.AuthCodeURL(RandomString) fmt.Println(url) http.Redirect(w,r,url,http.StatusTemporary Redirect) }
  • 26. ssogolang = &oauth2.Config{…} is to configure our backend code with our console app using the credentials we got from there. Further, we will enter the scope needed in the configuration. Here, we want the email id of the user so we’ve used []string{“https://www.googleapis.com/auth/ userinfo.email”}. This will our generated URL Explanation Generate the random string to uniquely identify user from the user state and then pass it to the AuthcodeUrl function from the OAuth package that generates URL with the required configuration
  • 27. package controllers import ( "context" "errors" "fmt" "io/ioutil" "log" "net/http" ) func Callback(w http.ResponseWriter, r *http.Request){ state :=r.FormValue("state") code := r.FormValue("code") data,err:=getUserData(state,code) if err!=nil{ log.Fatal("error getting user data") } // callback.go
  • 28. fmt.Fprintf(w,"Data : %s",data) } func getUserData(state,code string)([]byte,error){ if state != RandomString{ return nil,errors.New("invalid user state") } token,err:=ssogolang.Exchange(context.Backgroun d(),code) if err!=nil{ return nil,err } response,err :=http.Get("https://www.googleapis.com/oauth2/v2 /userinfo?access_token=" + token.AccessToken) if err!=nil{ return nil,err } defer response.Body.Close() data,err:=ioutil.ReadAll(response.Body) if err!=nil{ return nil,err } return data,nil }
  • 29. state :=r.FormValue(“state”) ,code := r.FormValue(“code”) This line of code will fetch the user state and code from Google console. Further, check the user state to uniquely identify the user with the help of if state != RandomString Exchange the code for a token using the Exchange(…) function, a part of OAuth flow using the OAuth library. Now get the user data from Google APIs using the token we got using this line of code response,err :=http.Get(“https://www.googleapis.com/o auth2/v2/userinfo?access_token=” + token.AccessToken) fExplanation
  • 31. So far we have covered the backend part for implementing SSO using OAuth in our golang app. Now, it’s time to write some front-end code. Open index.html and use the below code for the user interface. You can surely change the UI according to your wish. // index.html <div> <form action="/action_page.php"> <div class="row"> <h2 style="text-align:center"> Login with Social Media or Manually </h2> <div class="vl"> <span class="vl-innertext">or</span> </div> <div class="col">
  • 32. <a href="#" class="fb btn"> <i class="fa fa-facebook fa-fw"></i> Login with Facebook </a> <a href="#" class="twitter btn"> <i class="fa fa-twitter fa-fw"></i> Login with Twitter </a> <a href="/signin" class="google btn"> <i class="fa fa-google fa-fw"></i> Login with Google+ </a> </div> <div class="col"> <div class="hide-md-lg"> <p>Or sign in manually:</p> </div> <input type="text" name="username" placeholder="Username" required
  • 33. > <input type="password" name="password" placeholder="Password" required > <input type="submit" value="Login"> </div> </div> </form> <div class="bottom-container"> <div class="row"> <div class="col"> <a href="#" style="color:white" class="btn">Sign up</a> </div> <div class="col"> <a href="#" style="color:white" class="btn">Forgot password?</a> </div> </div> </div> </div>
  • 34. <a href=”/signin ”> will redirect you to the sign-in route when you click the button.
  • 36. If you want to clone the project and play around with the code then here’s the source code: sso-using-oauth-demo
  • 38. So, this was about how to implement SSO using OAuth in the Golang application. I hope the purpose of this step-by-step guideline has been served as expected. For more such Golang tutorials with github sources feel free to visit the Golang tutorials page. Bacancy has skilled developers with fundamental and advanced knowledge. Are you looking for a helping hand for your golang project? If yes, then without a second thought, contact our Golang developers