Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app-only authentication #167

Open
bilik opened this issue Aug 11, 2022 · 4 comments
Open

app-only authentication #167

bilik opened this issue Aug 11, 2022 · 4 comments

Comments

@bilik
Copy link

bilik commented Aug 11, 2022

Is it possible to use the library to login the application? For example: https://docs.microsoft.com/cs-cz/graph/tutorials/php?WT.mc_id=Portal-Microsoft_AAD_RegisteredApps&tabs=aad&tutorial-step=8
Thans.

@bilik
Copy link
Author

bilik commented Aug 15, 2022

There are a few differences from the basic procedure:

  1. "client_credentials" must be supplemented with the "scope" parameter:
    $scope = "$baseGraphUri/.default"; $token = self::$provider->getAccessToken('client_credentials', ['scope' => $scope]);
  2. [BUG] - public function getRootMicrosoftGraphUri($accessToken) function crashes on this token. There is a bug in field lookup and it is necessary to pass null instead of token.

@bilik
Copy link
Author

bilik commented Aug 15, 2022

$tenant = array_key_exists('tid', $idTokenClaims) ? $idTokenClaims['tid'] : $this->tenant; $version = array_key_exists('ver', $idTokenClaims) ? $idTokenClaims['ver'] : $this->defaultEndPointVersion;

If "$idTokenClaims" is null, which is a valid value, the array_key_exists function will throw an exception.

@hajekj
Copy link
Member

hajekj commented Sep 9, 2022

Hello, sorry for late reply.

I believe it should be possible - see sample here: https://github.com/TheNetworg/DreamSpark-SSO/blob/master/cron.php#L25

I understand that you are trying to use v2.0 endpoint with Microsoft Graph which requires scope, there might be some changes required to enable this behavior.

@Smig0l
Copy link

Smig0l commented Sep 28, 2023

any updates on adding client_credentials grant flow?
As of now MSFT addded support for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants