Comments (9)
import requests
import os
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
mgraphSecret = os.getenv('GRAPH_SECRET')
mgraphAppID = os.getenv('GRAPH_APP_ID')
mgraphTenant = os.getenv('TENANT_ID')
api_url = "https://login.microsoftonline.com/" + mgraphTenant + "/oauth2/token"
data = {
'resource': 'https://adnotifications.windowsazure.com/StrongAuthenticationService.svc/Connector',
'client_id': mgraphAppID,
'scope': 'openid',
'client_secret': mgraphSecret,
'grant_type': 'client_credentials',
}
response = requests.post(url=api_url, data=data)
response_data = response.json()
access_token = response_data['access_token']
emailAddressToPush = "[email protected]"
xml = '<BeginTwoWayAuthenticationRequest> \
<Version>1.0</Version>\
<UserPrincipalName>' + emailAddressToPush + '</UserPrincipalName>\
<Lcid>en-us</Lcid> \
<AuthenticationMethodProperties xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> \
<a:KeyValueOfstringstring> \
<a:Key>OverrideVoiceOtp</a:Key> \
<a:Value>true</a:Value> \
</a:KeyValueOfstringstring> \
</AuthenticationMethodProperties> \
<ContextId>69ff05bf-eb61-47f7-a70e-e7d77b6d47d0</ContextId> \
<SyncCall>true</SyncCall> \
<RequireUserMatch>true</RequireUserMatch> \
<CallerName>Pritunl Authy</CallerName> \
<CallerIP>UNKNOWN:</CallerIP> \
</BeginTwoWayAuthenticationRequest>'
response = requests.post(url="https://adnotifications.windowsazure.com/StrongAuthenticationService.svc/Connector//BeginTwoWayAuthentication", headers={"Authorization": "Bearer " + access_token, "Content-Type": "application/xml"}, data = xml)
print(response.content)
from azvalidate.
The server encountered an error processing the request. See server logs for more details.
from azvalidate.
from azvalidate.
i honestly have no clue. You seem to be missing a lot of code though, such as using the correct spn and generating password.
But, this is a powershell solution, not a python solution. Im not really sure why you are asking for help here.
As they say on the internet, Sir, this is a wendys
from azvalidate.
Can you confirm that the powershell script is still working?
from azvalidate.
Yup
from azvalidate.
Where does the RefreshToken and Genpass token come from? I have an AppID and AppSecret
Also what does spn stand for?
from azvalidate.
You can check out the docs here https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
from azvalidate.
Here is a version I made which only uses graph requests which might be easier to convert https://github.com/lwhitelock/AzValidate-1
and here is an improved version I tweaked for CIPP https://github.com/KelvinTegelaar/CIPP-API/blob/master/ExecSendPush/run.ps1
from azvalidate.
Related Issues (3)
- Quick Deploy from blog is broken HOT 1
- MFA Push HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azvalidate.