1- import React , { useCallback , useRef , useState } from 'react'
1+ import React , { useCallback , useState } from 'react'
22import './app.css'
33import { User } from './User'
44import {
@@ -11,8 +11,7 @@ import {
1111 LoginSocialMicrosoft ,
1212 LoginSocialPinterest ,
1313 LoginSocialTwitter ,
14- IResolveParams ,
15- TypeCrossFunction
14+ IResolveParams
1615} from 'reactjs-social-login'
1716
1817import {
@@ -28,69 +27,24 @@ import {
2827
2928import { ReactComponent as PinterestLogo } from './assets/pinterest.svg'
3029
31- const REDIRECT_URI = 'https://7923-123-16-241-177 .ap.ngrok.io/account/login'
30+ const REDIRECT_URI = 'https://20d3-1-55-164-102 .ap.ngrok.io/account/login'
3231// const REDIRECT_URI = 'http://localhost:3000/account/login'
3332
3433const App = ( ) => {
3534 const [ provider , setProvider ] = useState ( '' )
3635 const [ profile , setProfile ] = useState < any > ( )
37- const amazonRef = useRef < TypeCrossFunction > ( null ! )
38- const instagramRef = useRef < TypeCrossFunction > ( null ! )
39- const googleRef = useRef < TypeCrossFunction > ( null ! )
40- const facebookRef = useRef < TypeCrossFunction > ( null ! )
41- const microsoftRef = useRef < TypeCrossFunction > ( null ! )
42- const linkedinRef = useRef < TypeCrossFunction > ( null ! )
43- const githubRef = useRef < TypeCrossFunction > ( null ! )
44- const pinterestRef = useRef < TypeCrossFunction > ( null ! )
45- const twitterRef = useRef < TypeCrossFunction > ( null ! )
4636
4737 const onLoginStart = useCallback ( ( ) => {
4838 alert ( 'login start' )
4939 } , [ ] )
5040
51- const onLogoutFailure = useCallback ( ( ) => {
52- alert ( 'logout fail' )
53- } , [ ] )
54-
5541 const onLogoutSuccess = useCallback ( ( ) => {
5642 setProfile ( null )
5743 setProvider ( '' )
5844 alert ( 'logout success' )
5945 } , [ ] )
6046
61- const onLogout = useCallback ( ( ) => {
62- switch ( provider ) {
63- case 'amazon' :
64- amazonRef . current ?. onLogout ( )
65- break
66- case 'facebook' :
67- facebookRef . current ?. onLogout ( )
68- break
69- case 'google' :
70- googleRef . current ?. onLogout ( )
71- break
72- case 'instagram' :
73- instagramRef . current ?. onLogout ( )
74- break
75- case 'microsoft' :
76- microsoftRef . current ?. onLogout ( )
77- break
78- case 'github' :
79- githubRef . current ?. onLogout ( )
80- break
81- case 'pinterest' :
82- pinterestRef . current ?. onLogout ( )
83- break
84- case 'twitter' :
85- twitterRef . current ?. onLogout ( )
86- break
87- case 'linkedin' :
88- linkedinRef . current ?. onLogout ( )
89- break
90- default :
91- break
92- }
93- } , [ provider ] )
47+ const onLogout = useCallback ( ( ) => { } , [ ] )
9448
9549 return (
9650 < >
@@ -100,7 +54,6 @@ const App = () => {
10054 < div className = { `App ${ provider && profile ? 'hide' : '' } ` } >
10155 < h1 className = 'title' > ReactJS Social Login</ h1 >
10256 < LoginSocialFacebook
103- ref = { facebookRef }
10457 appId = { process . env . REACT_APP_FB_APP_ID || '' }
10558 fieldsProfile = {
10659 'id,first_name,last_name,middle_name,name,name_format,picture,short_name,email,gender'
@@ -119,11 +72,8 @@ const App = () => {
11972 </ LoginSocialFacebook >
12073
12174 < LoginSocialGoogle
122- ref = { googleRef }
12375 client_id = { process . env . REACT_APP_GG_APP_ID || '' }
124- onLogoutFailure = { onLogoutFailure }
12576 onLoginStart = { onLoginStart }
126- onLogoutSuccess = { onLogoutSuccess }
12777 onResolve = { ( { provider, data } : IResolveParams ) => {
12878 setProvider ( provider )
12979 setProfile ( data )
@@ -136,7 +86,6 @@ const App = () => {
13686 </ LoginSocialGoogle >
13787
13888 < LoginSocialAmazon
139- ref = { amazonRef }
14089 client_id = { process . env . REACT_APP_AMAZON_APP_ID || '' }
14190 redirect_uri = { REDIRECT_URI }
14291 onResolve = { ( { provider, data } : IResolveParams ) => {
@@ -147,13 +96,11 @@ const App = () => {
14796 console . log ( err )
14897 } }
14998 onLoginStart = { onLoginStart }
150- onLogoutSuccess = { onLogoutSuccess }
15199 >
152100 < AmazonLoginButton />
153101 </ LoginSocialAmazon >
154102
155103 < LoginSocialInstagram
156- ref = { instagramRef }
157104 client_id = { process . env . REACT_APP_INSTAGRAM_APP_ID || '' }
158105 client_secret = { process . env . REACT_APP_INSTAGRAM_APP_SECRET || '' }
159106 redirect_uri = { REDIRECT_URI }
@@ -171,11 +118,9 @@ const App = () => {
171118 </ LoginSocialInstagram >
172119
173120 < LoginSocialMicrosoft
174- ref = { microsoftRef }
175121 client_id = { process . env . REACT_APP_MICROSOFT_APP_ID || '' }
176122 redirect_uri = { REDIRECT_URI }
177123 onLoginStart = { onLoginStart }
178- onLogoutSuccess = { onLogoutSuccess }
179124 onResolve = { ( { provider, data } : IResolveParams ) => {
180125 setProvider ( provider )
181126 setProfile ( data )
@@ -188,12 +133,10 @@ const App = () => {
188133 </ LoginSocialMicrosoft >
189134
190135 < LoginSocialLinkedin
191- ref = { linkedinRef }
192136 client_id = { process . env . REACT_APP_LINKEDIN_APP_ID || '' }
193137 client_secret = { process . env . REACT_APP_LINKEDIN_APP_SECRET || '' }
194138 redirect_uri = { REDIRECT_URI }
195139 onLoginStart = { onLoginStart }
196- onLogoutSuccess = { onLogoutSuccess }
197140 onResolve = { ( { provider, data } : IResolveParams ) => {
198141 setProvider ( provider )
199142 setProfile ( data )
@@ -206,7 +149,6 @@ const App = () => {
206149 </ LoginSocialLinkedin >
207150
208151 < LoginSocialGithub
209- ref = { githubRef }
210152 client_id = { process . env . REACT_APP_GITHUB_APP_ID || '' }
211153 client_secret = { process . env . REACT_APP_GITHUB_APP_SECRET || '' }
212154 redirect_uri = { REDIRECT_URI }
@@ -223,12 +165,10 @@ const App = () => {
223165 < GithubLoginButton />
224166 </ LoginSocialGithub >
225167 < LoginSocialPinterest
226- ref = { pinterestRef }
227168 client_id = { process . env . REACT_APP_PINTEREST_APP_ID || '' }
228169 client_secret = { process . env . REACT_APP_PINTEREST_APP_SECRET || '' }
229170 redirect_uri = { REDIRECT_URI }
230171 onLoginStart = { onLoginStart }
231- onLogoutSuccess = { onLogoutSuccess }
232172 onResolve = { ( { provider, data } : IResolveParams ) => {
233173 setProvider ( provider )
234174 setProfile ( data )
@@ -247,9 +187,8 @@ const App = () => {
247187 </ LoginSocialPinterest >
248188
249189 < LoginSocialTwitter
250- ref = { twitterRef }
251- client_id = { process . env . REACT_APP_TWITTER_API_KEY || '' }
252- client_secret = { process . env . REACT_APP_TWITTER_APP_SECRET || '' }
190+ client_id = { process . env . REACT_APP_TWITTER_V2_APP_KEY || '' }
191+ // client_secret={process.env.REACT_APP_TWITTER_V2_APP_SECRET || ''}
253192 redirect_uri = { REDIRECT_URI }
254193 onLoginStart = { onLoginStart }
255194 onLogoutSuccess = { onLogoutSuccess }
0 commit comments