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

User Provided Authentication #987

Open
PvanHengel opened this issue Jul 20, 2023 · 9 comments
Open

User Provided Authentication #987

PvanHengel opened this issue Jul 20, 2023 · 9 comments

Comments

@PvanHengel
Copy link

Hi,

This library looks great, and the way it is plugged into langchain is super cool. Question: our users are already authenticated interactively through the front end of our app, and we have the access token required, is there a way we can bypass all the authentication logic, and just give the token? Ive been trying to fool it in the Account Setup, by passing a custom token backend seeded with the token, but pydantic and other places, do not allow it to work unless we call the authenticate function, which has a good amount of rigidity in its checks to get the user in various ways, but none let an external token /session to be provided. Any guidance would be great!

@alejcas
Copy link
Member

alejcas commented Jul 20, 2023

Yep you can either use the default tokenbackend and store the token as json in a file or define your own tockendbacked that get and sets the token somehow (environment, databade, etc). There are some already done tockendbackends like firebase and more.

@PvanHengel
Copy link
Author

agreed yes we can easily use different token stores, my issue is around how the token is acquired we have a react front end that does all the work and want to be able to pass the token to the python back end, basically no token store needed, the current flows as I understand it do not allow for the access token to be provided externally

@alejcas
Copy link
Member

alejcas commented Jul 21, 2023

To acquire the token (if you are authenticating on behalf of a user) check:

https://github.com/O365/python-o365#different-authentication-interfaces

There's is an example on how to do it using a web app interface

@PvanHengel
Copy link
Author

Thanks yea I saw that this flow assumes we are doing three legged and the back end, we are using pkce on front end so the token is maintained there using the msal library, we can pass the current token to the api on the back end when we make the request. This flow assumes the redirect and codes exchange for the token.

@djk1983
Copy link

djk1983 commented Dec 10, 2023

I am trying to achieve a similar thing. I have a Streamlit application that users sign in via MSAL so a token is already held.

From there I am struggling to ascertain how to pass the existing token to call O365 functions without directly authenticating via O365.

@alejcas
Copy link
Member

alejcas commented Dec 10, 2023

It should be possible to load the msal token info into a O364 token class.
It’s just json with the token info

i can look into it if you can extract this token info from msal

@djk1983
Copy link

djk1983 commented Dec 11, 2023

That would be very helpful. I can access the token, which is currently held in memory. I would like to avoid writing to disk as I have not yet created secure storage.

@alejcas
Copy link
Member

alejcas commented Jan 8, 2024

I didn't have time for this. But if you have access to the msal token you can extract the token info and load it into a token class then use it in O365

@akesh1235
Copy link

I have already authenticated my app with the Azur App Directory and obtained the necessary credentials. CLIENT_ID and CLIENT_SECRET.
But, When I am trying to connect LangChain by specifying credentials,
I am getting ERROR: AADSTS900971: No reply address provided.

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

4 participants