-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_auth_url.py
32 lines (21 loc) · 871 Bytes
/
get_auth_url.py
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
#!/usr/bin/python3
import urllib.parse
from mycommon import JsonFile
def get_fitbit_auth_url(auth_url, scope, client_id, redirect_uri):
# Using OAuth 2.0 — MB Web API Docs
# Authorization Code Grant Flow: Authorization Page
# https://developer.mercedes-benz.com/content-page/oauth-documentation
params = {
"client_id": client_id,
"response_type": "code",
"scope": scope,
"redirect_uri": redirect_uri,
}
qs = urllib.parse.urlencode(params)
return auth_url + "?" + qs
auth_url = "https://api.secure.mercedes-benz.com/oidc10/auth/oauth/v2/authorize"
scope = "mb:vehicle:status:general mb:user:pool:reader mb:vehicle:mbdata:evstatus"
auth = JsonFile("mb-auth.json").read()
mb_auth_url = get_fitbit_auth_url(
auth_url, scope, auth["client_id"], auth["callback_url"])
print("{}".format(mb_auth_url))