-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyNotes.text
90 lines (75 loc) · 2.42 KB
/
MyNotes.text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//ToDO: import library
//ToDo: create a main function
//ToDo: Create a widget
//ToDo: Run that widget on a mobile device
//ToDo: Create a widget
//* Write => and remove curly braces if the function executes only one statement
// sharepoint rest api urls
Future getListData(String accesstoken) async {
try {
http.Response response = await http.get(
Uri.encodeFull(Apikeys.sharepointListUrl),
headers: {
"Authorization": "Bearer " + accesstoken,
"Accept": "application/json"
},
);
var data = json.decode(response.body);
List rest = data["value"] as List;
for (var items in rest) {
print(items['Customer']);
}
} catch (e) {
print(e);
}
}
Future<Token> getSharepointToken() async {
http.Response response = await http.post(
Uri.encodeFull(Apikeys.sharepointTokenurl),
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: {
"grant_type": "client_credentials",
"client_id": Apikeys.sharepointClientId,
"client_secret": Apikeys.sharepointClientSecret,
"resource": Apikeys.sharepointResource,
},
);
Map<String, dynamic> tokenJson = json.decode(response.body);
print('Token Type : ' + tokenJson["token_type"]);
print('Expires In : ' + tokenJson["expires_in"]);
print('Not Before : ' + tokenJson["not_before"]);
print('Expires On : ' + tokenJson["expires_on"]);
print('Resource : ' + tokenJson["resource"]);
print('Access Token : ' + tokenJson["access_token"]);
Token token = new Token.fromJson(tokenJson);
return token;
}
/// Request tenant id
import 'dart:async';
import 'package:http/http.dart' as http;
class RequestTenantId {
RequestTenantId();
Future<String> requestTenantId() async {
String code;
http.Response response = await http.get(
Uri.encodeFull(
"https://spmautomation.sharepoint.com/sites/SPMConnect/sharepoint.com/_vti_bin/client.svc/"),
headers: {
"Authorization": "Bearer",
},
);
// response.headers.forEach((k, v) {
// print('Header: $k, value: $v');
// });
var data = (response.headers["www-authenticate"]);
List rest = data.split(',');
print(rest[0]);
code = rest[0];
return code;
}
}
permission:
git:
url: https://github.com/devadrianapostol/permission