PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, September 4, 2022

[FIXED] How to authenticate users with social logins in web widget?

 September 04, 2022     authentication, supabase, widget     No comments   

Issue

I have a web widget which other users can embed on to their own websites. The widget is built with vanilla JS and no external libraries, whilst I'm using a node.js backend. And the widget requires users to login to interact with it.

When logging in with email and password on the widget, I send that information to my server and return back with a token if it's a registered user.

However, I am unsure as to how I can do the same with social logins (e.g. google) without having to download any external libraries. How can I allow a user to log in to google and pass the user details back to the widget? Are there any examples of this?

  • Widget - VanillaJS
  • Dashboard Frontend - ReactJS
  • Dashboard backend - Node.js
  • Database - Supabase

Solution

yes there are examples of this here https://ui.supabase.io/components/auth#social-providers

when your user is authenticated by a social provider, the email address is provided like so:

import { Auth, Typography, Button } from '@supabase/ui'
import { createClient } from '@supabase/supabase-js'

const supabase = createClient('https://your-project-url.supabase.co', 'PROJECT_ANON_KEY')

const Container = (props) => {
  const { user } = Auth.useUser()
  if (user)
    return (
      <>
        <Typography.Text>Signed in: {user.email}</Typography.Text>


Answered By - Greg Willson
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing