-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathmicrosoft-graph-api-auth.html
More file actions
166 lines (150 loc) · 7.44 KB
/
microsoft-graph-api-auth.html
File metadata and controls
166 lines (150 loc) · 7.44 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1" />
<title>Microsoft Graph API Auth</title>
<link href='https://fonts.loli.net/icon?family=Material+Icons' rel='stylesheet'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
</head>
<body>
<nav>
<div class="nav-wrapper">
<a href="#" class="brand-logo center">Microsoft Graph API Auth</a>
<ul id="nav-mobile" class="right hide-on-med-and-down">
<li><a href="..">More tools</a></li>
<li><a href="https://idx0.dev">My blog</a></li>
<li><a href="https://github.com/heymind/heymind.github.io/blob/master/tools/microsoft-graph-api-auth.html">Source Code</a></li>
</ul>
</div>
</nav>
<div class="container">
<div class="card">
<div class="card-content">
<span class="card-title">Prerequisite</span>
<ol>
<li>
<p>Open <a
href="https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade">https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade</a>
to register a new app.</p>
<p>This tool requires that the <code>redirect_uri</code> = <code><span
id="location"></span></code></p>
</li>
<li>
<p>Switch to <code>Certificates & secrets</code> tab, create a <code>client secret</code> ,
copy
and paste it to the input box below.</p>
</li>
<li>
<p>Switch to <code>API permissions</code> tab, add permissions you need.</p>
<p>For OneDrive Index purpose, select following permssions: <code>offline_access</code>,
<code>Files.Read</code>, <code>Files.Read.All</code> .</p>
<p> </p>
</li>
</ol>
</div>
</div>
<form class="card" action="https://login.microsoftonline.com/common/oauth2/v2.0/authorize" method="GET">
<div class="card-content">
<span class="card-title">4. Authorize for code</span>
<div class="input-field">
<input placeholder="client_id" name="client_id" type="text">
<label for="client_id">Client ID</label>
</div>
<div class="input-field">
<input placeholder="offline_access," name="scope" type="text"
value="offline_access Files.Read Files.Read.All">
<label for="scope">Scope</label>
</div>
<div class="input-field">
<input placeholder="Placeholder" name="redirect_uri" type="text">
<label for="redirect_uri">Redirect Uri</label>
</div>
<input name="response_type" type="text" hidden value="code">
</div>
<div class="card-action">
<input type="submit" value="Authorize" class="waves-effect waves-teal btn-flat" />
</div>
</form>
<form class="card" action="https://login.microsoftonline.com/common/oauth2/v2.0/token" method="POST">
<div class="card-content">
<span class="card-title">5. Exchange Access Token</span>
<div class="input-field">
<input placeholder="client_id" name="client_id" type="text">
<label for="client_id">Client ID</label>
</div>
<div class="input-field">
<input placeholder="offline_access," name="client_secret" type="text">
<label for="client_secret">Client Secret</label>
</div>
<div class="input-field">
<input placeholder="offline_access," name="code" type="text">
<label for="scope">Code</label>
</div>
<div class="input-field">
<input placeholder="Placeholder" name="redirect_uri" type="text">
<label for="redirect_uri">Redirect Uri</label>
</div>
</div>
<input name="grant_type" type="text" hidden value="authorization_code">
<div class="card-action">
<input type="submit" value="Get Token" class="waves-effect waves-teal btn-flat" />
</div>
</form>
<form class="card" action="https://login.microsoftonline.com/common/oauth2/v2.0/token" method="POST">
<div class="card-content">
<span class="card-title">Refresh Token</span>
<div class="input-field">
<input placeholder="client_id" name="client_id" type="text">
<label for="client_id">Client ID</label>
</div>
<div class="input-field">
<input placeholder="offline_access," name="client_secret" type="text">
<label for="client_secret">Client Secret</label>
</div>
<div class="input-field">
<input placeholder="offline_access," name="refresh_token" type="text">
<label for="refresh_token">Refresh Token</label>
</div>
<div class="input-field">
<input placeholder="Placeholder" name="redirect_uri" type="text">
<label for="redirect_uri">Redirect Uri</label>
</div>
</div>
<input name="grant_type" type="text" hidden value="refresh_token">
<div class="card-action">
<input type="submit" value="Get Token" class="waves-effect waves-teal btn-flat" />
</div>
</form>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<style>
.card-title {
padding-bottom: 1 rem;
}
</style>
<script>
function syncField(name, value) {
if (!value) value = localStorage.getItem(name);
if (value)
document.querySelectorAll(`input[name=${name}]`).forEach(ii => ii.value = value);
document.querySelectorAll(`input[name=${name}]`).forEach((i) => i.onchange = (e) => {
localStorage.setItem(name, e.target.value);
document
.querySelectorAll(`input[name=${name}]`).forEach(ii => ii.value = e.target.value)
});
}
window.onload = function () {
syncField("client_id");
syncField("redirect_uri", window.location.protocol + "//" + window.location.host + window.location.pathname);
document.querySelector("#location").textContent = window.location.protocol + "//" + window.location.host + window.location.pathname;
const params = (new URL(document.location)).searchParams;
let code = params.get("code");
if (code) {
alert(`Got Code ${code}`);
document.querySelector("input[name=code]").value = code;
}
}
</script>
</body>
</html>