(code)
| 162 | return oauthCode |
| 163 | |
| 164 | def FinishAuthorization(code): |
| 165 | payload = urllib.parse.urlencode({ |
| 166 | "grant_type": "authorization_code", |
| 167 | "code": code, |
| 168 | "redirect_uri": OAuthRedirectUri, |
| 169 | "scope": OAuthScope, |
| 170 | "client_id": OAuthClientId, |
| 171 | }) |
| 172 | |
| 173 | headers = { 'content-type': "application/x-www-form-urlencoded" } |
| 174 | |
| 175 | conn = http.client.HTTPSConnection(osmHost) |
| 176 | conn.request("POST", "/oauth2/token", payload, headers) |
| 177 | |
| 178 | res = conn.getresponse() |
| 179 | if res.status >= 400: |
| 180 | print(res.status) |
| 181 | print(res.headers) |
| 182 | print(res.read().decode('utf-8')) |
| 183 | raise Exception("Error getting OAuth2 token") |
| 184 | |
| 185 | return res.read().decode("utf-8") |
| 186 | |
| 187 | |
| 188 | def FindAuthenticityToken(formAction, htmlCode): |
no test coverage detected