@@ -96,7 +96,8 @@ Console](https://console.developers.google.com/flows/enableapi?apiid=drive).
96
96
## Solid
97
97
98
98
An authentication URL must always have been set on the Solid backend before
99
- calling ` connect() ` . You can do so by calling ` setAuthURL() ` first.
99
+ calling ` connect() ` . You can do so by calling ` remoteStorage.solid.setAuthURL() `
100
+ first.
100
101
101
102
The connect widget accepts a list of authentication URLs as configuration
102
103
and automatically sets it on the Solid backend when selected.
@@ -112,3 +113,59 @@ from the [Inrupt](https://docs.inrupt.com/developer-tools/javascript/client-libr
112
113
Solid library. It can be accessed by calling ` remoteStorage.solid.getSession() `
113
114
only after the backend is connected.
114
115
:::
116
+
117
+ ### Conneting to Solid without the widget
118
+
119
+ [ Solid] ( https://solidproject.org/ ) is an open standard for structuring data,
120
+ digital identities, and applications on the Web.
121
+
122
+ In order to connect to a Solid pod i.e. storage, the first step is to
123
+ authenticate with a Solid Identity Provider which is achieved by first calling
124
+ ` solid.setAuthURL() ` and then calling ` solid.connect() ` .
125
+
126
+ Solid supports multiple storage pods for each user. So after successfully
127
+ authenticating, you'll need to get a list of available pods for that user and
128
+ pick one to be used by the remote storage library. A successful authentication
129
+ process fires the ` pod-not-selected ` event after calling connect. Upon
130
+ receiving this event you must call ` solid.getPodURLs() ` to get a list of
131
+ available pods. There is usually only one pod per user but it can be any number
132
+ starting from zero.
133
+
134
+ Call ` solid.setPodURL() ` after deciding which pod to use. The widget
135
+ automatically selects the pod if there is only one available. Prompts the user
136
+ if there are multiple available and shows an error if there is none. After
137
+ setting the pod URL, you'll immediately receive the ` connected ` event.
138
+
139
+ ::: info
140
+ If the connection process has reached the ` pod-not-selected ` step, the progress
141
+ is saved and the next time the page refreshes, you'll receive event and can
142
+ continue from there.
143
+ :::
144
+
145
+ Calling ` connect() ` always ends up in redirecting the page to the identity
146
+ provider website. So does future page loads after a successful authentication.
147
+ Upon returning, the response bears if the user still has access. This means
148
+ that the page never loads with the connected state. It'll take a few moments
149
+ and if everything is fine, ` connected ` is an event that is always fired.
150
+
151
+ A basic code that doesn't use the widget will look like this:
152
+ ``` js
153
+ const connectTask = setTimeout (() => {
154
+ remoteStorage .solid .setAuthURL (' solid-identity-provider-url' ); // i.e. https://login.inrupt.com
155
+ remoteStorage .solid .connect ();
156
+ // Calling 'connect()' will immediately redirect to the identity provider website.
157
+ }, 1000 );
158
+ remoteStorage .on (' pod-not-selected' , () => {
159
+ clearTimeout (connectTask);
160
+ const podURLs = remoteStorage .solid .getPodURLs ();
161
+ // Choose one. Maybe there is even 0?
162
+ remoteStorage .solid .setPodURL (podURLs[0 ]);
163
+ // That's it. 'connected' is fired immediately.
164
+ };
165
+ remoteStorage .on (' connected' , () => {
166
+ // We are connected.
167
+ clearTimeout (connectTask);
168
+ // We arrive here either through calling 'setPodURL' on the `pod-not-selected` event or
169
+ // on page getting loaded.
170
+ });
171
+ ` ` `
0 commit comments