且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从PHP Web应用程序连接到Azure Active Directory

更新时间:2023-11-24 18:02:04

There are several scenarios Azure AD supports, depend on what you use Azure AD for. Basically, to access the resources via Azure AD from PHP web application, you can refer to Web Application to Web API section to understand this scenario and get started.

To integrate Azure AD in PHP web applications, we need to follow authorization code grant flow steps to build several custom HTTP requests. E.G. To get access token via OAuth 2.0 protocol, we should refer to the steps on Authorization Code Grant Flow, generally, we will build 2 HTTP requests to get access token:

1,Request an authorization code

The build-up URL will redirect to the sso page, after login we can get the code value which will be used in next step.

2,Use the Authorization Code to Request an Access Token:

Then we can use the access token to add the JWT string with a "Bearer" designation in the Authorization header of the request to the resource web API.

Here is a PHP test project provided by Azure for your reference.