@@ -62,7 +62,7 @@ class ParseUser extends ParseObject implements ParseCloneable {
6262
6363 ParseUser .forQuery () : super (keyClassUser);
6464
65- createUser (String username, String password, [ String emailAddress]) {
65+ static createUser ([ String username, String password, String emailAddress]) {
6666 return ParseUser (username, password, emailAddress);
6767 }
6868
@@ -206,6 +206,44 @@ class ParseUser extends ParseObject implements ParseCloneable {
206206 }
207207 }
208208
209+ // Logs in a user using a service
210+ static Future <ParseUser > loginWith (String provider, Object authData) async {
211+ ParseUser user = ParseUser .createUser ();
212+ var response = await user._loginWith (provider, authData);
213+ if (response.success) {
214+ return user;
215+ } else {
216+ return Future .error (response);
217+ }
218+ }
219+
220+ Future <ParseResponse > _loginWith (String provider, Object authData) async {
221+ try {
222+ Uri tempUri = Uri .parse (_client.data.serverUrl);
223+
224+ Uri url = Uri (
225+ scheme: tempUri.scheme,
226+ host: tempUri.host,
227+ path: "${tempUri .path }$keyEndPointUsers " ,
228+ );
229+
230+ final response = await _client.post (url,
231+ headers: {
232+ keyHeaderRevocableSession: "1" ,
233+ },
234+ body: jsonEncode ({
235+ "authData" : {
236+ provider: authData
237+ }
238+ }));
239+
240+ return _handleResponse (
241+ this , response, ParseApiRQ .loginWith, _debug, className);
242+ } on Exception catch (e) {
243+ return _handleException (e, ParseApiRQ .loginWith, _debug, className);
244+ }
245+ }
246+
209247 /// Sends a request to delete the sessions token from the
210248 /// server. Will also delete the local user data unless
211249 /// deleteLocalUserData is false.
0 commit comments