diff --git a/bskyweb/cmd/bskyweb/server.go b/bskyweb/cmd/bskyweb/server.go index 8da291fe56..4584f42279 100644 --- a/bskyweb/cmd/bskyweb/server.go +++ b/bskyweb/cmd/bskyweb/server.go @@ -223,6 +223,7 @@ func serve(cctx *cli.Context) error { e.GET("/intent/compose", server.WebGeneric) e.GET("/messages", server.WebGeneric) e.GET("/messages/:conversation", server.WebGeneric) + e.GET("/auth/callback", server.WebGeneric) // profile endpoints; only first populates info e.GET("/profile/:handleOrDID", server.WebProfile) diff --git a/bskyweb/static/.well-known/client-metadata.json b/bskyweb/static/.well-known/client-metadata.json index 1c363edb26..d5a15922ee 100644 --- a/bskyweb/static/.well-known/client-metadata.json +++ b/bskyweb/static/.well-known/client-metadata.json @@ -1,11 +1,11 @@ { - "client_id": "https://bsky.app/.well-known/client-metadata.json", + "client_id": "https://.ngrok-free.app/.well-known/client-metadata.json", "client_name": "Bluesky", - "client_uri": "https://bsky.app", + "client_uri": "https://.ngrok-free.app", "logo_uri": "https://bsky.app/logo.png", "tos_uri": "https://bsky.social/about/support/tos", "policy_uri": "https://bsky.social/about/support/privacy-policy", - "redirect_uris": ["https://bsky.app/auth/callback"], + "redirect_uris": ["https://.ngrok-free.app/auth/callback"], "scope": "profile email offline_access", "grant_types": ["authorization_code", "refresh_token"], "response_types": ["code"], diff --git a/src/Navigation.tsx b/src/Navigation.tsx index 79856879c3..f9b9d62845 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -41,6 +41,7 @@ import {PreferencesThreads} from 'view/screens/PreferencesThreads' import {SavedFeeds} from 'view/screens/SavedFeeds' import {SharedPreferencesTesterScreen} from '#/screens/E2E/SharedPreferencesTesterScreen' import HashtagScreen from '#/screens/Hashtag' +import {CallbackScreen} from '#/screens/Login/CallbackScreen' import {ModerationScreen} from '#/screens/Moderation' import {ProfileKnownFollowersScreen} from '#/screens/Profile/KnownFollowers' import {ProfileLabelerLikedByScreen} from '#/screens/Profile/ProfileLabelerLikedBy' @@ -364,6 +365,11 @@ function commonScreens(Stack: typeof HomeTab, unreadCountLabel?: string) { getComponent={() => Wizard} options={{title: title(msg`Edit your starter pack`), requireAuth: true}} /> + CallbackScreen} + options={{title: title(msg`Callback`)}} + /> ) } diff --git a/src/lib/routes/types.ts b/src/lib/routes/types.ts index 0cc83b475a..8bd0fd27c5 100644 --- a/src/lib/routes/types.ts +++ b/src/lib/routes/types.ts @@ -50,6 +50,7 @@ export type CommonNavigatorParams = { StarterPackShort: {code: string} StarterPackWizard: undefined StarterPackEdit: {rkey?: string} + AuthCallback: undefined } export type BottomTabNavigatorParams = CommonNavigatorParams & { diff --git a/src/screens/Login/CallbackScreen.tsx b/src/screens/Login/CallbackScreen.tsx index 11a54352d1..d3be19d0e6 100644 --- a/src/screens/Login/CallbackScreen.tsx +++ b/src/screens/Login/CallbackScreen.tsx @@ -1,7 +1,31 @@ import React from 'react' +import {AppBskyActorDefs} from '@atproto/api' -import {ListMaybePlaceholder} from '#/components/Lists' +import {CenteredView} from 'view/com/util/Views' +import {client} from '#/screens/Login/LoginForm' +import {Text} from '#/components/Typography' export function CallbackScreen() { - return + const [profile, setProfile] = React.useState() + React.useEffect(() => { + ;(async () => { + const res = await client.init() + const profileRes = await res!.agent.request( + '/xrpc/com.atproto.repo.getRecord?' + + new URLSearchParams({ + repo: res!.agent.sub, + collection: 'app.bsky.actor.profile', + rkey: 'self', + }).toString(), + ) + const json = await profileRes?.json() + setProfile(json.value) + })() + }, []) + + return ( + + {profile ? profile.displayName : 'Loading'} + + ) } diff --git a/src/screens/Login/LoginForm.tsx b/src/screens/Login/LoginForm.tsx index e0c84c9b61..4df88aaaf2 100644 --- a/src/screens/Login/LoginForm.tsx +++ b/src/screens/Login/LoginForm.tsx @@ -27,7 +27,7 @@ import {logger} from '#/logger' import {useSessionApi} from '#/state/session' import {useLoggedOutViewControls} from '#/state/shell/logged-out' import {useRequestNotificationsPermission} from 'lib/notifications/notifications' -import {useGate} from 'lib/statsig/statsig' +// import {useGate} from 'lib/statsig/statsig' import {useSetHasCheckedForStarterPack} from 'state/preferences/used-starter-packs' import {atoms as a, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' @@ -43,13 +43,13 @@ import {FormContainer} from './FormContainer' type ServiceDescription = ComAtprotoServerDescribeServer.OutputSchema -const client = new BrowserOAuthClient({ +export const client = new BrowserOAuthClient({ plcDirectoryUrl: 'https://plc.directory', handleResolver: 'https://bsky.social', clientMetadata: { - client_id: 'http://localhost:19006/', - redirect_uris: ['http://localhost:19006/auth/callback'], - response_types: ['code'], + client_id: 'https://.ngrok-free.app/.well-known/client-metadata.json', + client_name: 'Bluesky', + redirect_uris: ['https://.ngrok-free.app/auth/callback'], token_endpoint_auth_method: 'none', }, }) @@ -186,8 +186,8 @@ export const LoginForm = ({ const {setShowLoggedOut} = useLoggedOutViewControls() const setHasCheckedForStarterPack = useSetHasCheckedForStarterPack() - const gate = useGate() - const oauthEnabled = __DEV__ || gate('use_oauth') + // const gate = useGate() + const oauthEnabled = true const oauth = useOAuth(client) const [handle, setHandle] = React.useState('')