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

Add access_token property to UserInformation #393

Closed
fileman opened this issue May 8, 2019 · 15 comments
Closed

Add access_token property to UserInformation #393

fileman opened this issue May 8, 2019 · 15 comments
Assignees
Labels
auth Related to App Center's Auth service feature request New feature request

Comments

@fileman
Copy link

fileman commented May 8, 2019

Describe the solution you'd like
Since MSAL is used under the cover, if AuthenticationResult has access_token value add to new property in UserInformation.

Describe alternatives you've considered
Continue to use MSAL to AzureAD B2C

Additional context
even AcquireTokenSilent with refresh_token... if not handled inside the SignInAsync method

@fileman fileman added the feature request New feature request label May 8, 2019
@patniko patniko added the auth Related to App Center's Auth service label May 8, 2019
@amchew
Copy link
Contributor

amchew commented May 8, 2019

Hi @fileman, thanks for commenting! Could you share more details about your scenario please?

@guperrot
Copy link
Member

guperrot commented May 8, 2019

Hi, to rephrase you want UserInformation to have the AccessToken property being available?

As for refresh token, it is already handled, if you call SignInAsync again (after a successful first time), the second time it will be a silent sign-in.

@fileman
Copy link
Author

fileman commented May 8, 2019

Yes, so I can use it when I have to invoke bearer protected web api, azure functions, odata endpoint, etc... something like I do now with azure mobile apps.

@amchew
Copy link
Contributor

amchew commented May 8, 2019

Thanks @fileman, I've added this feature request to our backlog. Others - feel free to give a thumbs up if this is a feature you'd like to see.

@fileman fileman changed the title AppCenter.Auth UserInformation access_token Add access_token property to UserInformation May 9, 2019
@amchew
Copy link
Contributor

amchew commented May 10, 2019

Hey @fileman! Just wanted to let you know that we’re created a feature to return and expose the access token (JWT) to users in the signIn() method, and will be working on it shortly. Will update again when it’s live.

@futie
Copy link

futie commented May 18, 2019

I also need the ability to retrieve the JWT if the user is already signed in or can be signed in silently. Ideally a call to SignIn with a (bool silent=True) parameter - this can then be called when the UI is being rendered - to display a 'Login' or 'Logout' button as appropriate.

@amchew
Copy link
Contributor

amchew commented May 21, 2019

Hi @futie, thanks for the feedback, and got it on your feature request to return whether the user is signed in is true. We have a feature that will be worked on soon to return the JWT in the signIn() method, so you can check if the JWT is null or not. If it's null, it means that the user has not signed in; else the user has signed in. The workaround you can do now is to store the account_id that is returned in the signIn() method as a local variable, then to check if the variable is null or not.

For both @futie and @fileman, we're always looking for feedback to improve Auth, would you be available to hop on a call with me to learn more about your experience? Email me at amchew [at] microsoft [dot] com.

@blparr blparr mentioned this issue May 23, 2019
18 tasks
@brad302
Copy link

brad302 commented Jun 6, 2019

@amchew @guperrot

> As for refresh token, it is already handled, if you call SignInAsync again (after a successful first time), the second time it will be a silent sign-in.

Just in relation to the above, yes, my experience is that it will pass straight through but if you have more than one identity provider enabled, the user will be presented with the provider selection screen and then once selected and if previously authenticated, it will silently pass through.

It would be nice to have a refresh token for the last successful login with the relevant provider so we can pass that straight through without even prompting the user to open the b2c webview login control.

Maybe I'm missing something but that's been my experience and a more seamless one would be really handy. Apologies if this enhancement is being handled as a part of a future release already but I just wanted to get my 2 cents in.

I also concur re: the bearer token, to have that would be absolute gold. Specifically for Azure AD in a corporate sense, to be able to use that token (if possible) to other O365 and Azure based services would be extremely beneficial.

Again, I hope I'm not speaking out of turn.

@amchew
Copy link
Contributor

amchew commented Jun 6, 2019

Hey @brad302, in our next release of the SDK (sometime in the third week of Jun - will keep y'all updated!), we will be exposing the access token and id token. You should be able to determine based on the token whether to show the user the login UI or not.

For example,

var user=null;
try {
    user = Auth.SignIn();
} catch() {...}

if (jwt != null) // detect signin
doWork();

Would that work for your scenario?

Not sure if you really need the refresh token for this scenario. Let us know if you do, and what you're using it for.

Never apologize. We really appreciate all the feedback! 👯‍♂

@amchew
Copy link
Contributor

amchew commented Jun 7, 2019

Hi @fileman, @futie, @brad302 (and @landrzz, @sdg85)!

An update: we completed the work to expose the access and id token today and this will be released in the next version of our SDK - before the end of June.

We'll be sharing in our documentation how to parse the access and id token, what actions to take if the user is signed in or not. Also, with today's current feature set, you can determine if the user is signed in or not by calling SignInAsync again. If you do that, the SDK will not show the sign-in UI again, it will only do so if the saved sign-in information has expired or has been revoked by the authentication server.

@brad302
Copy link

brad302 commented Jun 7, 2019

@amchew you guys rock, massive thanks! I'll keep an eye out for it and feedback where appropriate.

@fileman
Copy link
Author

fileman commented Jun 10, 2019

@amchew is there appcenter nightly/myget CI build?

@amchew
Copy link
Contributor

amchew commented Jun 25, 2019

Hey @fileman, @futie, @brad302, @landrzz, @sdg85, @masatoru, @damienaicheh, you can now get the access and id tokens for Auth in the 2.1.0 Android, iOS SDK and 2.1.1 Xamarin SDK releases!

Here are the repos and documentation for the following platforms:-

Xamarin

iOS

For iOS Cocoapods users, you need to bump version of Podfile and run pod install. If you're doing the manual iOS integration, you'll need the repo above.

Android

You can upgrade the versions via Visual Studio or Android Studio (bump version or follow the warning in Gradle).

Try it out, and let us know what you think! :)

@fileman
Copy link
Author

fileman commented Jun 25, 2019

@amchew is exactly what I need!
I close this issue because it is solved, if someone need something else, please open a new issue.

@supreettare
Copy link

Hey Guys,
Am I missing something?

I am using the latest stable version of Auth 2.6.1 on both Xamarin Android & iOS head projects as well is in my .Net Standard project (mine is a Xamarin Forms solution)

I am calling SignInAsync every single time the app starts. Here is what I observe:
On Android: The first time I get a login screen, I enter my credentials & hit Login, I get the tokens.
On the 2nd run onward, SignInAsync is still called, but I do not get a Login UI. It just auto logs in.

On iOS: First run shows login window & when correct credentials are added, it authenticates successfully. However. it keeps showing the login window on every subsequent calls as well.

Am I missing something? Should I not call SignInAsync every single time & make it conditional based on certain conditions? If yes, what conditions?

Your help on this is really appreciated.

Thanks
ST

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Related to App Center's Auth service feature request New feature request
Projects
None yet
Development

No branches or pull requests

7 participants