@@ -23,6 +23,7 @@ import {
2323 SignOutScope ,
2424 GoTrueAdminOAuthApi ,
2525 CreateOAuthClientParams ,
26+ UpdateOAuthClientParams ,
2627 OAuthClientResponse ,
2728 OAuthClientListResponse ,
2829} from './lib/types'
@@ -66,6 +67,7 @@ export default class GoTrueAdminApi {
6667 listClients : this . _listOAuthClients . bind ( this ) ,
6768 createClient : this . _createOAuthClient . bind ( this ) ,
6869 getClient : this . _getOAuthClient . bind ( this ) ,
70+ updateClient : this . _updateOAuthClient . bind ( this ) ,
6971 deleteClient : this . _deleteOAuthClient . bind ( this ) ,
7072 regenerateClientSecret : this . _regenerateOAuthClientSecret . bind ( this ) ,
7173 }
@@ -414,9 +416,7 @@ export default class GoTrueAdminApi {
414416 *
415417 * This function should only be called on a server. Never expose your `service_role` key in the browser.
416418 */
417- private async _createOAuthClient (
418- params : CreateOAuthClientParams
419- ) : Promise < OAuthClientResponse > {
419+ private async _createOAuthClient ( params : CreateOAuthClientParams ) : Promise < OAuthClientResponse > {
420420 try {
421421 return await _request ( this . fetch , 'POST' , `${ this . url } /admin/oauth/clients` , {
422422 body : params ,
@@ -457,6 +457,33 @@ export default class GoTrueAdminApi {
457457 }
458458 }
459459
460+ /**
461+ * Updates an existing OAuth client.
462+ * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
463+ *
464+ * This function should only be called on a server. Never expose your `service_role` key in the browser.
465+ */
466+ private async _updateOAuthClient (
467+ clientId : string ,
468+ params : UpdateOAuthClientParams
469+ ) : Promise < OAuthClientResponse > {
470+ try {
471+ return await _request ( this . fetch , 'PUT' , `${ this . url } /admin/oauth/clients/${ clientId } ` , {
472+ body : params ,
473+ headers : this . headers ,
474+ xform : ( client : any ) => {
475+ return { data : client , error : null }
476+ } ,
477+ } )
478+ } catch ( error ) {
479+ if ( isAuthError ( error ) ) {
480+ return { data : null , error }
481+ }
482+
483+ throw error
484+ }
485+ }
486+
460487 /**
461488 * Deletes an OAuth client.
462489 * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
@@ -467,15 +494,10 @@ export default class GoTrueAdminApi {
467494 clientId : string
468495 ) : Promise < { data : null ; error : AuthError | null } > {
469496 try {
470- await _request (
471- this . fetch ,
472- 'DELETE' ,
473- `${ this . url } /admin/oauth/clients/${ clientId } ` ,
474- {
475- headers : this . headers ,
476- noResolveJson : true ,
477- }
478- )
497+ await _request ( this . fetch , 'DELETE' , `${ this . url } /admin/oauth/clients/${ clientId } ` , {
498+ headers : this . headers ,
499+ noResolveJson : true ,
500+ } )
479501 return { data : null , error : null }
480502 } catch ( error ) {
481503 if ( isAuthError ( error ) ) {
0 commit comments