Python Forum
Python & MSGraph - Learning to Walk - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python & MSGraph - Learning to Walk (/thread-41548.html)



Python & MSGraph - Learning to Walk - ITMan020324 - Feb-03-2024

Hello Pythoneers,

I am trying to create a console application where it will ask for AAD User email address, validate if exists and if it does not exist add the user into two Azure AD groups, do some validation as well. I have registered the application in Azure, I have the application id, client id, client secret and the respective permissions.

I would like to have some guidance in be able connect successfully. I have python installed and I am using Visual Studio Code

One more thing I did create a code using Azure PowerShell, but the thing is that I need to create an executable.

I know there are tons of stuff out there, but I try to make it work in my environment and most of the time errors out.

Thanks for your help,


RE: Python & MSGraph - Learning to Walk - Pedroski55 - Feb-04-2024

Don't know what Azure is, must be some kind of cloud-based database.

If you want to validate the email, you probably want a password too, I think. Anyone can get an email address alone.

I think this kind of login will happen on a webpage form, and interaction with the user will be via webpages, so why not use PHP?

First, you look for the email in the db table, if the email is found, check the password. If that is OK, let the user in.

A very basic PHP login script:

Quote:<?php
//start new PHP session array
session_start();
//check if login form is submitted
if(isset($_POST['login'])){
//assign variables to post values
$email = $_POST['email'];
$password = $_POST['password'];
//include our database connection
include 'conn.php';
//get the user with email
$stmt = $pdo->prepare('SELECT * FROM mydbtable WHERE email = :email');
try{
$stmt->execute(['email' => $email]);
//check if email in this instance exists
if($stmt->rowCount() > 0){
//get the row
$user = $stmt->fetch();
//validate the password with $user[password]
if(password_verify($password, $user['password'])){
//action after a successful login
//for now just message a successful login
$_SESSION['success'] = 'User verification successful';
catch (PDOException $e){
$_SESSION['exception'] = $e->getMessage();
}
// if email and password are OK, go to the desired webpage
header('location: mywebpage.html.php');
exit();
}
?>


But I would prefer a Linux server!

Also, you should show what code you have tried here, along with the error messages you get, or how can the people here help you?


RE: Python & MSGraph - Learning to Walk - ITMan020324 - Feb-04-2024

Unfortunately PHP will not work,,the main purpose of what I am looking for is if I am not available and a laptop failed. The end user will ask the person in charge if I am not availble to execute the executable application (.exe), it will run, will ask for email address and in the background will process what I said in the thread...