FabianLars / tauri-plugin-oauth

Apache License 2.0
79 stars 20 forks source link

Feature request: Configurable "Please return to the app." screen #10

Closed VojGin closed 6 months ago

VojGin commented 6 months ago

Hey thanks for the plugin!

I have a feature request:

According to this line

Right now the plugin displays almost empty HTML page with:

<html><head>{}</head><body>Please return to the app.</body></html>

I was thinking about pushing in a custom .html file, that would get loaded instead using include_str!("success.html") Replacing the end of a head tag as so .replace("</head>", "{}</head>")

And then continuing as usual.

Such as this:

let success_html = include_str!(path_to_html_file)
succes_html = success_html.replace("</head>", "{}</head>")

format!(
  succes_html
  script
)

I'm just struggling with passig the path_to_html_file to the plugin. Not even sure what would be the best method for it. 🤷‍♂️ Been thinking about an argument in the ::init method for the plugin. But I'd be glad to get your opinion on this.

Thanks! 🙌

FabianLars commented 6 months ago

Hi, thanks for reaching out! What you're asking for is already possible and your link actually points to the logic that handles custom responses (specifically you linked to the fallback if no response was provided).

To use it you simply have to use start_with_config instead of start, it takes an OauthConfig object where you can set the response string. Paths aren't and won't be supported so you'll have to do the include_str part in your own code before you give it to the plugin.

Closing this issue but please continue discussing this here if the current solution does not work for you :)

VojGin commented 6 months ago

Ah, thanks alot! 🙏 Sorry, didn't see it. 😅 Can we maybe have a bit of documentation for the plugin in the readme please? Maybe atleast a link to the docs here

FabianLars commented 6 months ago

Yeah, at some point it will have proper docs. tbh i never thought i'd keep this plugin around for so long (or at least in this form). I'll see where i can fit it into my todo list.