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