-
-
Notifications
You must be signed in to change notification settings - Fork 206
Log in with token #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yeah, that looks like a nice implementation of it. Is it fully tested and
working?
…On Sun, Jan 27, 2019, 12:50 Pablo ***@***.*** wrote:
Hey, I need to login the user from a token. What do you think about this
code? I can do a PR if its ok.
Future<ParseResponse> getCurrentUserFromServer({token}) async {
// We can't get the current user and session without a sessionId
if(token==null && _client.data.sessionId == null) {
return null;
}
if(token == null){
token = _client.data.sessionId;
}
try {
Uri tempUri = Uri.parse(_client.data.serverUrl);
Uri uri = Uri(
scheme: tempUri.scheme,
host: tempUri.host,
path: "${tempUri.path}$keyEndPointUserName");
final response = await _client.get(uri, headers: {keyHeaderSessionToken: token});
return _handleResponse(response, ParseApiRQ.currentUser);
} on Exception catch (e) {
return _handleException(e, ParseApiRQ.currentUser);
}
}
With this changes, I can do the following:
initUserFromToken () async{
ParseUser user = new ParseUser(null,null,null);
var response = await user.getCurrentUserFromServer(token:"r:78095e44937ff1732f18ea04d04ad67e");
if (response.success){
user = await ParseUser.currentUser();
print("user"+user.get(ParseUser.keyUsername));
}
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#58>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AHgn3uehrd_HJmmCWIkSXQqFl5PMrYnpks5vHaCugaJpZM4aUs2P>
.
|
Yes its tested, the function initUser() in main its working like a charm, and the snippet that I included here its working too. |
Perfect. Please create a PR and I'll merge them.
Thank you for your work!
…On Sun, Jan 27, 2019, 13:44 Pablo ***@***.*** wrote:
Yes its tested, the function initUser() in main its working like a charm,
and the snippet that I included here its working too.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#58 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHgn3sc6zbSVdVvbM_q9LZOIQEqUBIwlks5vHa1AgaJpZM4aUs2P>
.
|
Merged
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, I need to login the user from a token. What do you think about this code? I can do a PR if its ok.
With this changes, I can do the following:
The text was updated successfully, but these errors were encountered: