rm some useless code
This commit is contained in:
+1
-11
@@ -1,7 +1,7 @@
|
||||
import {isWeb} from 'platform/detection'
|
||||
|
||||
export const OAUTH_CLIENT_ID = 'http://localhost/'
|
||||
export const OAUTH_REDIRECT_URI = 'http://127.0.0.1:5173/'
|
||||
export const OAUTH_REDIRECT_URI = 'http://127.0.0.1:2583/'
|
||||
export const OAUTH_SCOPE = 'openid profile email phone offline_access'
|
||||
export const OAUTH_GRANT_TYPES = [
|
||||
'authorization_code',
|
||||
@@ -10,13 +10,3 @@ export const OAUTH_GRANT_TYPES = [
|
||||
export const OAUTH_RESPONSE_TYPES = ['code', 'code id_token'] as const
|
||||
export const DPOP_BOUND_ACCESS_TOKENS = true
|
||||
export const OAUTH_APPLICATION_TYPE = isWeb ? 'web' : 'native' // TODO what should we put here for native
|
||||
|
||||
export const buildOAuthUrl = (serviceUrl: string, state: string) => {
|
||||
const url = new URL(serviceUrl)
|
||||
url.searchParams.set('client_id', OAUTH_CLIENT_ID)
|
||||
url.searchParams.set('redirect_uri', OAUTH_REDIRECT_URI)
|
||||
url.searchParams.set('response_type', OAUTH_RESPONSE_TYPES.join(' '))
|
||||
url.searchParams.set('scope', OAUTH_SCOPE)
|
||||
url.searchParams.set('state', state)
|
||||
return url.toString()
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import React from 'react'
|
||||
import * as Browser from 'expo-web-browser'
|
||||
|
||||
import {
|
||||
buildOAuthUrl,
|
||||
DPOP_BOUND_ACCESS_TOKENS,
|
||||
OAUTH_APPLICATION_TYPE,
|
||||
OAUTH_CLIENT_ID,
|
||||
@@ -14,7 +13,7 @@ import {
|
||||
import {RNOAuthClientFactory} from '../../../../modules/expo-bluesky-oauth-client'
|
||||
|
||||
// Service URL here is just a placeholder, this isn't how it will actually work
|
||||
export function useLogin(serviceUrl: string | undefined) {
|
||||
export function useLogin() {
|
||||
const openAuthSession = React.useCallback(async () => {
|
||||
const oauthFactory = new RNOAuthClientFactory({
|
||||
clientMetadata: {
|
||||
@@ -29,24 +28,19 @@ export function useLogin(serviceUrl: string | undefined) {
|
||||
fetch: global.fetch,
|
||||
})
|
||||
|
||||
const res = await oauthFactory.signIn('http://localhost:2583/')
|
||||
console.log(res)
|
||||
const url = await oauthFactory.signIn('http://localhost:2583/')
|
||||
|
||||
return
|
||||
|
||||
if (!serviceUrl) return
|
||||
|
||||
const url = buildOAuthUrl(serviceUrl, '123') // TODO replace '123' with the appropriate state
|
||||
console.log(url.href)
|
||||
|
||||
const authSession = await Browser.openAuthSessionAsync(
|
||||
url, // This isn't actually how this will work
|
||||
OAUTH_REDIRECT_URI, // Replace this as well with the appropriate link
|
||||
url.href,
|
||||
OAUTH_REDIRECT_URI,
|
||||
)
|
||||
|
||||
if (authSession.type !== 'success') {
|
||||
return
|
||||
}
|
||||
}, [serviceUrl])
|
||||
}, [])
|
||||
|
||||
return {
|
||||
openAuthSession,
|
||||
|
||||
Reference in New Issue
Block a user