-
Notifications
You must be signed in to change notification settings - Fork 14
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
is there any examples #4
Comments
yes, I can provide some example in library description, but a bit later this week. I put some code here for you
|
I was just reading it and decided to write the same comment with Dart formatting for better visuals. class AuthRepositoryImpl extends AuthRepository {
final String _clientAudience;
Auth0Client _auth;
AuthRepositoryImpl(String baseUrl, String clientId, this._clientAudience) {
_auth = Auth0Client(
clientId: clientId,
domain: baseUrl,
connectTimeout: timeout.inMilliseconds,
sendTimeout: timeout.inMilliseconds,
useLoggerInterceptor: false,
receiveTimeout: 60000);
}
@override
Future<dynamic> register(String login, String password) async {
dynamic response = await _auth.createUser({
'email': login,
'password': password,
'connection': 'Username-Password-Authentication'
});
}
@override
Future<Auth0User> login(String login, String password) async {
Auth0User response = await _auth.passwordRealm({
'username': login,
'password': password,
'scope': 'openid email profile offline_access',
'audience': _clientAudience,
'realm': 'Username-Password-Authentication'
});
await PreferenceManager().setAccessToken(response.accessToken);
await PreferenceManager().setRefreshToken(response.refreshToken);
return response;
}
@override
Future<dynamic> getUserInfo() async {
dynamic response = await _auth.getUserInfo();
return response;
}
@override
Future<String> refreshToken(String refreshToken) async {
dynamic response = await _auth.refreshToken({"refreshToken": refreshToken});
await PreferenceManager().setAccessToken(response["access_token"]);
return response["access_token"];
}
@override
Future<dynamic> logout() async {
await PreferenceManager().clear();
var response = await _auth.logout();
return response;
}
@override
Future<String> resetPassword(String login) async {
dynamic response = await _auth.resetPassword(
{'email': login, 'connection': 'Username-Password-Authentication'});
return response;
}
@override
void setBearer(String token) {
_auth.updateToken(token);
}
}
|
thanks for the contributing |
Sorry if this question was already answered or if the answer was obvious, but when I used the sample code above, dart is having an issue finding the AuthRepository class (the class that is being extended). Where do I find this class that is being expanded. For imports, I only have the auth0 import: Thanks in advance. |
This is an example. AuthRepository is in abstract class (like an interface). You could use it as you want |
could you please share some example? how to use it step by step for beginners. Thank you
The text was updated successfully, but these errors were encountered: