ags_authrest2 1.0.6
ags_authrest2: ^1.0.6 copied to clipboard
ags_authrest project.
Usage #
to /example
folder.
** For auth midleware https://www.npmjs.com/package/ags_authrest
import 'package:ags_authrest2/ags_authrest.dart';
import 'package:http/http.dart' as http;
Exlample() async {
var auth = Ags_restauth();
auth.SECERT_JWT = 'ihavealongpassword';
auth.R_USER = 'karantest';
// body + headers
var headers = {
'path': 'test',
'port': '5016',
'Authorization': auth.genTokenEncryp(), // gentoken and encryp
'Content-Type': 'application/json'
};
var bodyData = {
"phone": "+66885257777",
"otpCode": "778747",
"refCode": "orxh4f",
"fromBU": "Qsms"
};
//
var body = json.encode(bodyData);
var request = http.Request('POST', Uri.parse('http://localhost:3999/'));
request.body = json.encode(auth.encrypbody(body)); //encrypbody
request.headers.addAll(headers);
print(request.body);
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
print(await response.stream.bytesToString());
} else {
print(response.reasonPhrase);
}
}