mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Moving to JSON instead of FormData for oauth
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import {
|
||||
QueryFunctionContext,
|
||||
useMutation,
|
||||
UseMutationOptions,
|
||||
useQuery,
|
||||
UseQueryOptions
|
||||
QueryFunctionContext,
|
||||
useMutation,
|
||||
UseMutationOptions,
|
||||
useQuery,
|
||||
UseQueryOptions
|
||||
} from '@tanstack/react-query'
|
||||
import apiGeneral from '@utils/api/general'
|
||||
import apiInstance from '@utils/api/instance'
|
||||
@ -29,24 +29,23 @@ const useAppsQuery = (
|
||||
return useQuery(queryKey, queryFunctionApps, params?.options)
|
||||
}
|
||||
|
||||
type MutationVarsApps = { domain: string }
|
||||
type MutationVarsApps = { domain: string; scopes: string[] }
|
||||
|
||||
export const redirectUri = AuthSession.makeRedirectUri({
|
||||
native: 'tooot://instance-auth',
|
||||
useProxy: false
|
||||
})
|
||||
const mutationFunctionApps = async ({ domain }: MutationVarsApps) => {
|
||||
const formData = new FormData()
|
||||
formData.append('client_name', 'tooot')
|
||||
formData.append('website', 'https://tooot.app')
|
||||
formData.append('redirect_uris', redirectUri)
|
||||
formData.append('scopes', 'read write follow push')
|
||||
|
||||
const mutationFunctionApps = async ({ domain, scopes }: MutationVarsApps) => {
|
||||
return apiGeneral<Mastodon.Apps>({
|
||||
method: 'post',
|
||||
domain: domain,
|
||||
url: `api/v1/apps`,
|
||||
body: formData
|
||||
url: 'api/v1/apps',
|
||||
body: {
|
||||
client_name: 'tooot',
|
||||
website: 'https://tooot.app',
|
||||
redirect_uris: redirectUri,
|
||||
scopes: scopes.join(' ')
|
||||
}
|
||||
}).then(res => res.body)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user