-
Notifications
You must be signed in to change notification settings - Fork 205
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
Support On-Behalf-Of flow #53
Comments
Very much required. Anything to assist you with that? |
@dudil Thanks for reaching out! We appreciate assistant from community on:
|
@rayluo Is there any progress on this? Seems like 0.6.0 is scheduled for July 22nd - is that still on track? |
Already implemented some of the flows (need to update my read-me...) Thanks! |
@dudil: I don't see the code for on-behalf-of flow in: https://github.com/dudil/py365/blob/master/py365/auth/msal_connection.py - nor is there a different branch on that repo. Nor do I see a fork you've made of this library. Where are the flows implemented? |
Hi @dsanghan - I didn't implement that since it is not working yet. If you wish me to fork and implemented I can try but as I understood you already developed that - did you? |
Hi folks, thanks for your interest and sorry for some confusions here.
UPDATE at 2019-7-22: That ADFS 2019 PR is technically ready to go, but we hold off for a little longer to conduct some internal review/discussion. (PS: We don't normally provide progress update on a delayed release, but based on the conversations above, we figure it might be helpful for audience here.) |
Hi @dudil , remember you mentioned this?
Now the time has come. :-) Please try #92. CC: @dsanghan @sohels @arindam-laha who also expressed interest in this feature. |
@rayluo Not working for us.
The JWT access token was created using https://github.com/AzureAD/microsoft-authentication-library-for-objc on the v2 endpoint with scope: The issued JWT token from the objc library works for our requests, and refreshes on the V2 endpoint without issue. Code to reproduce:
I verified
Any ideas? |
@dsanghan Glad to have you onboard for testing. :-) You mentioned that your access token was obtained by MSAL for Objc, with scope OBO is typically used by your confidential app, which is running on your backend server, between your front-end app and the downstream service. Please refer to the description in this issue. |
@rayluo The aud claim, and the app id are indeed different. I'm trying to use OBO since it matches the use case you described. The front-end app is where a user logs in. Since on iOS, you cannot run indefinite network connections, we have a confidential app on a backend server that checks for new emails OBO the user using EWS, if the user opts in for it. IF there is a new email, it sends a notification to the front-end app. AFAIK, this should be a valid OBO use case. If I can't use OBO for this, what do you suggest? Sending the refresh / access tokens from MSAL objc straight to my backend server for usage? |
Hi - Sorry to jump in the middle of it, I was busy in the last few days so was kind of out of the loop.
For public access token, you either need a specific user consent via the permission page. For the confidential access token, you will need to have an app secret from the AAD configuration page. Without going into too many picky details - So when do you need to use the OBO? In my case, I have an administrative service but the API I'm trying to use is not supporting the application permission type (the Planner API) I hope this makes more sense now... @rayluo - I will try the changes hopefully today/tomorrow and update. |
Quick comment to @dsanghan : In your scenario, sending access token (AT) and refresh token (RT) to your backend, which uses same client_id as your mobile app, can be a valid option. In fact, that is described as an "other strategies present themselves" alternative in the On-Behalf-Of doc in its "use of a single application" section. |
@rayluo Ok I'll try it out. What's interesting is that MSAL objc seem to be discouraging this use case: AzureAD/microsoft-authentication-library-for-objc#618 - they have purposefully not given access to the refresh token. While it's not hard to add the relevant code to get it, I wonder why there is a discrepancy here? |
@rayluo I was able to use the same refresh token on the backend to get / update access tokens, so seems like everything is working. Still curious why MSAL objc recommended OBO in the above linked issue. |
@dsanghan : I believe that you shoud not pass the refresh token to your backend (just the access token). Once the refresh token is used, it may not be usable again, and should be immediately replaced by the new RT you obtained from OBO |
@jmprieur As @rayluo pointed out, OBO won't work in our case. When I try to get a new pair of access/refresh tokens via OBO, the user assertion is rejected with a signature verification failure since the audience value is different from the client ID (since the JWT token is for EWS, acquired using MSAL objc). Ideally I'd use OBO but doesn't seem to work. More details as described above. |
@dsanghan : would you want to apply a technics like presented in 3.-Web-api-call-Microsoft-same-client-id in the ASP.NET Core Web API tutorial (I know it's not Python, but the principle would still apply) |
Released in version 0.7.0 |
The following description is derived from a description, written by @psignoret:
To illustrate how this works, let's suppose you have the following:
With the on-behalf-of flow, the following would happen:
Authorization
HTTP header).Step 4, above, will be very easily invoked with MSAL Python:
app.acquire_token_on_behalf_of(user_assertion, scopes)
In the signature above,
scopes
would be the scope(s) of DynamicsAPI (e.g.["https://contoso.crm.dynamics.com/.default"]
),app
is a confidential client representing BackendAPI, anduser_assertion
is what contains the access token that ClientApp originally obtained for BackendAPI.Here's a quick diagram illustrating the token and API requests happening:
The text was updated successfully, but these errors were encountered: