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

Commit 4281f6d

Browse files
authored
Merge pull request #422 from appwrite/1.4.x
1.4.x
2 parents 74a503f + f563606 commit 4281f6d

42 files changed

Lines changed: 7734 additions & 2412 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<p>
2+
Anonymous sessions allow you to implement guest users.
3+
Guest users let you store user information like items in their cart or theme preferences before they create an account.
4+
This reduces the friction for your users to get started with your app.
5+
</p>
6+
7+
<p>
8+
If a user <b>later creates an account</b>, their information will be inherited by the newly created account.
9+
</p>
10+
11+
<h2><a href="#createSession" id="createSession">Create Anonymous Session</a></h2>
12+
<p>
13+
Create an anonymous session with <a href="/docs/client/account#accountCreateAnonymousSession">Create Anonymous Session</a> route.
14+
</p>
15+
16+
17+
<ul class="phases clear" data-ui-phases>
18+
<li>
19+
<h3>Web</h3>
20+
<div class="ide" data-lang="javascript" data-lang-label="Web SDK">
21+
<pre class="line-numbers"><code class="prism language-javascript" data-prism>import { Client, Account } from "appwrite";
22+
23+
const client = new Client()
24+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
25+
.setProject('[PROJECT_ID]'); // Your project ID
26+
27+
const account = new Account(client);
28+
29+
const promise = account.createAnonymousSession();
30+
31+
promise.then(function (response) {
32+
console.log(response); // Success
33+
}, function (error) {
34+
console.log(error); // Failure
35+
});</code></pre>
36+
</div>
37+
</li>
38+
<li>
39+
<h3>Flutter</h3>
40+
<div class="ide" data-lang="dart" data-lang-label="Flutter SDK">
41+
<pre class="line-numbers"><code class="prism language-dart" data-prism>import 'package:appwrite/appwrite.dart';
42+
43+
final client = Client()
44+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
45+
.setProject('[PROJECT_ID]'); // Your project ID
46+
47+
final account = Account(client);
48+
49+
final user = await account.createAnonymousSession();</code></pre>
50+
</div>
51+
</li>
52+
<li>
53+
<h3>Android</h3>
54+
<div class="ide" data-lang="kotlin" data-lang-label="Android SDK">
55+
<pre class="line-numbers"><code class="prism language-kotlin" data-prism>import io.appwrite.Client
56+
import io.appwrite.services.Account
57+
58+
val client = Client()
59+
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
60+
.setProject("[PROJECT_ID]") // Your project ID
61+
62+
val account = Account(client)
63+
64+
val user = account.createAnonymousSession()</code></pre>
65+
</div>
66+
</li>
67+
<li>
68+
<h3>Apple</h3>
69+
<div class="ide" data-lang="swift" data-lang-label="Apple SDK">
70+
<pre class="line-numbers"><code class="prism language-swift" data-prism>import Appwrite
71+
72+
let client = Client()
73+
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
74+
.setProject("[PROJECT_ID]") // Your project ID
75+
76+
let account = Account(client)
77+
78+
let user = try await account.createAnonymousSession()</code></pre>
79+
</div>
80+
</li>
81+
<li>
82+
<h3>GraphQL</h3>
83+
<div class="ide" data-lang="graphql" data-lang-label="GraphQL">
84+
<pre class="line-numbers"><code class="prism language-graphql" data-prism>
85+
mutation {
86+
accountCreateAnonymousSession {
87+
_id
88+
userId
89+
provider
90+
expire
91+
}
92+
}</code></pre>
93+
</div>
94+
</li>
95+
</ul>
96+
97+
<h2><a href="#attach-account" id="attach-account">Attaching an Account</a></h2>
98+
<p>
99+
Anonymous users cannot sign back in.
100+
If the session expires, they move to another computer, or they clear their browser data, they won't be able to log in again.
101+
Remember to prompt the user to create an account to not lose their data.
102+
</p>
103+
104+
<p>
105+
Create an account with any of these methods to transition from an anonymous session to a user account session.
106+
</p>
107+
108+
109+
<p>
110+
<a href="/docs/authentication-email-pass"><i class="icon-angle-circled-right margin-start-negative-tiny margin-end-tiny">Email and password</a>
111+
</p>
112+
<p>
113+
<a href="/docs/authentication-sms"><i class="icon-angle-circled-right margin-start-negative-tiny margin-end-tiny">Phone (SMS)</a>
114+
</p>
115+
<p>
116+
<a href="/docs/authentication-magic"><i class="icon-angle-circled-right margin-start-negative-tiny margin-end-tiny">Magic URL</a>
117+
</p>
118+
<p>
119+
<a href="/docs/authentication-oauth"><i class="icon-angle-circled-right margin-start-negative-tiny margin-end-tiny">OAuth2</a>
120+
</p>

0 commit comments

Comments
 (0)