2021-10-04 14:20:29 +02:00
|
|
|
import {createRandomID} from '@/helpers/randomId'
|
|
|
|
|
2021-08-15 12:02:29 +02:00
|
|
|
interface Provider {
|
|
|
|
name: string
|
|
|
|
key: string
|
|
|
|
authUrl: string
|
|
|
|
clientId: string
|
|
|
|
}
|
|
|
|
|
|
|
|
export const redirectToProvider = (provider: Provider, redirectUrl: string) => {
|
2021-10-04 14:20:29 +02:00
|
|
|
const state = createRandomID(24)
|
2021-08-15 12:02:29 +02:00
|
|
|
localStorage.setItem('state', state)
|
|
|
|
|
|
|
|
window.location.href = `${provider.authUrl}?client_id=${provider.clientId}&redirect_uri=${redirectUrl}${provider.key}&response_type=code&scope=openid email profile&state=${state}`
|
|
|
|
}
|