From 076a7973cb0f68f70c33615c06e86ee918cd6d75 Mon Sep 17 00:00:00 2001 From: Alex Meesters Date: Wed, 26 Oct 2022 15:10:46 +0200 Subject: [PATCH 1/3] Added GetUser method. Required to validate a JWT on a backend service. --- Gotrue/Client.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Gotrue/Client.cs b/Gotrue/Client.cs index e10e685..a0dce8e 100644 --- a/Gotrue/Client.cs +++ b/Gotrue/Client.cs @@ -539,6 +539,23 @@ public async Task GetUserById(string jwt, string userId) throw ExceptionHandler.Parse(ex); } } + + /// + /// Get User details by JWT. Can be used to validate a JWT. + /// + /// A valid JWT. Must be a JWT that originates from a user. + /// + public async Task GetUser(string jwt) + { + try + { + return await api.GetUser(jwt); + } + catch (RequestException ex) + { + throw ExceptionHandler.Parse(ex); + } + } /// /// Create a user (as a service_role) From 1fa84a5fefa243e69b8fe9eefcf477be05f84355 Mon Sep 17 00:00:00 2001 From: Alex Meesters Date: Wed, 26 Oct 2022 15:14:50 +0200 Subject: [PATCH 2/3] Update Client.cs --- Gotrue/Client.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Gotrue/Client.cs b/Gotrue/Client.cs index a0dce8e..41e663a 100644 --- a/Gotrue/Client.cs +++ b/Gotrue/Client.cs @@ -541,21 +541,21 @@ public async Task GetUserById(string jwt, string userId) } /// - /// Get User details by JWT. Can be used to validate a JWT. - /// - /// A valid JWT. Must be a JWT that originates from a user. - /// - public async Task GetUser(string jwt) + /// Get User details by JWT. Can be used to validate a JWT. + /// + /// A valid JWT. Must be a JWT that originates from a user. + /// + public async Task GetUser(string jwt) + { + try + { + return await api.GetUser(jwt); + } + catch (RequestException ex) { - try - { - return await api.GetUser(jwt); - } - catch (RequestException ex) - { throw ExceptionHandler.Parse(ex); - } } + } /// /// Create a user (as a service_role) From d43a4644ec86601ef46d35c36b3496e99249df48 Mon Sep 17 00:00:00 2001 From: Alex Meesters Date: Wed, 26 Oct 2022 15:16:17 +0200 Subject: [PATCH 3/3] Update Client.cs --- Gotrue/Client.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gotrue/Client.cs b/Gotrue/Client.cs index 41e663a..5c51281 100644 --- a/Gotrue/Client.cs +++ b/Gotrue/Client.cs @@ -553,7 +553,7 @@ public async Task GetUser(string jwt) } catch (RequestException ex) { - throw ExceptionHandler.Parse(ex); + throw ExceptionHandler.Parse(ex); } }