Skip to content
This repository was archived by the owner on Sep 29, 2023. It is now read-only.

Commit 7033e73

Browse files
Merge pull request #117 from appwrite/feat-flutter-oauth-web
2 parents e034653 + b9ae23a commit 7033e73

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

app/views/docs/getting-started-for-flutter.phtml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,24 @@ $version = (isset($versions['flutter'])) ? $versions['flutter'] : '';
7979

8080
<p>Appwrite 0.7, and the Appwrite Flutter SDK 0.3.0 have added support for Flutter Web. To build web apps that integrate with Appwrite successfully, all you have to do is add a web platform on your Appwrite project's dashboard and list the domain your website will use to allow communication to the Appwrite API.</p>
8181

82+
<p>For web in order to capture the OAuth2 callback URL and send it to the application using JavaScript <code>postMessage()</code>, you need to create an html file inside <code>./web</code> folder of your Flutter project. For example <code>auth.html</code> with the following content.</p>
83+
84+
<div class="ide" data-lang="html" data-lang-label="html">
85+
<pre class="line-numbers"><code class="prism language-html" data-prism><?php echo $this->escape('<!DOCTYPE html>
86+
<title>Authentication complete</title>
87+
<p>Authentication is complete. If this does not happen automatically, please
88+
close the window.
89+
<script>
90+
window.opener.postMessage({
91+
\'flutter-web-auth\': window.location.href
92+
}, window.location.origin);
93+
window.close();
94+
</script>'); ?>
95+
</code></pre>
96+
</div>
97+
98+
<p>Redirection URL passed to the authentication service must be the same as the URL on which the application is running (schema, host, port if necessary) and the path must point to created HTML file, /auth.html in this case. The callbackUrlScheme parameter of the authenticate() method does not take into account, so it is possible to use a schema for native platforms in the code.</p>
99+
82100
<div class="notice">
83101
<h2>Flutter Web Cross-Domain Communication & Cookies</h2>
84102
<p>While running Flutter Web, make sure your Appwrite server and your Flutter client are using the same top-level domain and the same protocol (HTTP or HTTPS) to communicate. When trying to communicate between different domains or protocols, you may receive HTTP status error 401 because some modern browsers block cross-site or insecure cookies for enhanced privacy. In production, Appwrite allows you set multiple <a href="/docs/custom-domains">custom-domains</a> for each project.</p>

0 commit comments

Comments
 (0)