LanceMcCarthy / MvpApi

An application for Microsoft MVPs to easily browse and upload contributions
MIT License
36 stars 10 forks source link

Bearer Token Issue when using an AAD and an MSA #41

Closed LanceMcCarthy closed 2 years ago

LanceMcCarthy commented 6 years ago

For some profile photos, the Base64 is invalid or is failing to convert:

Exception Format_BadBase64Char. 
LanceMcCarthy commented 6 years ago

Attempting to apply a MIME check before decoding the base 64 might resolve this. Since the first few characters of the string contain the file extension, I'll automatically have the MIME type!

The following should do the trick:

base64String = base64String.TrimStart('"').TrimEnd('"');

var data = base64String.Substring(0, 5);

var fileExtension = string.Empty;

switch (data.ToUpper())
{
    case "IVBOR":
        fileExtension = "png";
        break;
    case "/9J/4":
        fileExtension = "jpg";
         break;
}

var imageData = base64String.Substring(5, base64String.Length);
var imgBytes = Convert.FromBase64String(imageData);
ReedKimble commented 6 years ago

Tried the update from a local build, got this error message now: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

LanceMcCarthy commented 6 years ago

Thanks @ReedKimble this brings me closer to the problem with some images. It seems that there are still characters.

Since you're running it locally, can you put a breakpoint here

https://github.com/LanceMcCarthy/MvpApi/blob/e5235e289bb15b8e7dbd7e5efe8ec9bb35348707/MvpApi.Uwp/Services/MvpApiService.cs#L180

and copy the value of base64string into your clipboard and email it to me? This would help me fix this once and for all.

ReedKimble commented 6 years ago

Well, that is interesting…. Check this out, this is the value of base64string:

{"Message":"Not able to find user","MessageDetail":"The e-mail address given, , did not match to an ID for user lookup","StatusCode":400}

I’ll note that when I originally became an MVP it was under a different email address than I use now. I had two linked to my live.com profile, the old one being a company email. I’m no longer with that company so just use the live.com address now. The old email was though I’m not sure that helps.

I wonder if this is something that Betsy will have to sort out for us on the MVP site side of things?

LanceMcCarthy commented 6 years ago

AHA! That, I believe, is the common thread between the folks who have this issue.

I'm in the middle of reaching out to some folks internally (and in the WinDev alias) to find out who works on the API. I'll update this thread as soon as I know more.

This looks like a legitimate API bug.

ReedKimble commented 6 years ago

Excellent! Glad we found something to go on. I'll keep an eye out for an update and test again when needed.

LanceMcCarthy commented 6 years ago

Small update. Definitely a common thread. I'm in the process of testing using multiple account login (Azure AD and MSA). This is a completely different approach using UWP's WebAccountProvider (that square popup you from the OS that has your already logged in accounts).

I've already got MSA working in a test branch, but Azure AD requires additional tokens for access. I'll let you know when you can try the test branch.

LanceMcCarthy commented 6 years ago

@ReedKimble This may have been fixed in #52 , during testing for a different OAuth issue @Depechie discovered that his Base64 started working after re-adding the scopes.

Let me know after you test v1.6.1 when it rolls out. Thanks!

LanceMcCarthy commented 6 years ago

@ReedKimble Can you try the latest update (1.7) and tell me if the problem is resolved? https://www.microsoft.com/store/apps/9NRXNX3WLH77

LanceMcCarthy commented 6 years ago

Close as duplicate thread confirmed fix. Will reopen if Reed replies with information that problem still exists for him.

ReedKimble commented 6 years ago

I’m trying to update but keep getting an error (Code: 0x80073CFB) during the download.

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: Lance McCarthy notifications@github.com Sent: Thursday, October 4, 2018 10:16:59 AM To: LanceMcCarthy/MvpApi Cc: Reed Kimble; Mention Subject: Re: [LanceMcCarthy/MvpApi] Base64 sometimes fails to convert (#41)

@ReedKimblehttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FReedKimble&data=02%7C01%7C%7C4eb37e544e4843afb47808d62a040c99%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636742594203488937&sdata=tEz%2BH0%2FQGoV8LQSzC03fYPtGLnZg6OjjvPRO8d7mx34%3D&reserved=0 Can you try the latest update (1.7) and tell me if the problem is resolved?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FLanceMcCarthy%2FMvpApi%2Fissues%2F41%23issuecomment-427036082&data=02%7C01%7C%7C4eb37e544e4843afb47808d62a040c99%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636742594203488937&sdata=jLxSpANTOKVR4r0Da9TnVuBcJ0IB%2BNHK3E7laXc2PFA%3D&reserved=0, or mute the threadhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMXHVIOLwY76u5jMPlHzUkRIOrMIfJO5ks5uhhhbgaJpZM4S8D3u&data=02%7C01%7C%7C4eb37e544e4843afb47808d62a040c99%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636742594203488937&sdata=gAq9z10Rlo0S0M%2F%2FFSwsGDpV%2BNsVnrt948LrfrhkDv8%3D&reserved=0.

LanceMcCarthy commented 6 years ago

Hi @ReedKimble ,

I've seen this before across a multitude of apps, it's a windows Store problem :/

One thing that comes to mind, is that the new version has a minimum requirement of Fall Creators Update (Windows 10, v 16299), are you running an earlier version of Windows 10?

A few things you can try:

  1. Uninstall the current version first.
  2. If that doesn't work, uninstall again and manually delete the app's local installation folder:

C:\Users[USERNAME]\AppData\Local\Packages\61469LanceLotSoftware.MVPCompanion_m6f3850p49bnt\

  1. Use the Windows Store repair tool, this will fix store caching issues (it doesn't touch app data)
    1. Open start menu
    2. Search for wsreset (you'll need to type the whole thing before it shows int he results)
    3. Run the command
ReedKimble commented 6 years ago

I think my OS version is ok – 1803 build 17134.285

I did an uninstall and wsreset then was able to install the 1.7 version.

Unfortunately, the error with the Base64 still exists…

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: Lance McCarthy notifications@github.com Sent: Thursday, October 4, 2018 4:45:50 PM To: LanceMcCarthy/MvpApi Cc: Reed Kimble; Mention Subject: Re: [LanceMcCarthy/MvpApi] Base64 sometimes fails to convert (#41)

Hi @ReedKimblehttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FReedKimble&data=02%7C01%7C%7C54febb892286444c8fe208d62a3a5f01%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636742827517408736&sdata=LbJrBr3OkC0UX13neubWNyp5fyCguNhWclcsSL6KAOs%3D&reserved=0 ,

I've seen this before across a multitude of apps, it's a windows Store problem :/

One thing that comes to mind, is that the new version has a minimum requirement of Fall Creators Update (Windows 10, v 16299), are you running an earlier version of Windows 10?

A few things you can try:

  1. Uninstall the current version first.
  2. If that doesn't work, uninstall again and manually delete the app's local installation folder:

C:\Users[USERNAME]\AppData\Local\Packages\61469LanceLotSoftware.MVPCompanion_m6f3850p49bnt

  1. Use the Windows Store repair tool, this will fix store caching issues (it doesn't touch app data)
    • Open start menu
    • Search for wsreset (you'll need to type the whole thing before it shows int he results)
    • Run the command

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FLanceMcCarthy%2FMvpApi%2Fissues%2F41%23issuecomment-427163195&data=02%7C01%7C%7C54febb892286444c8fe208d62a3a5f01%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636742827517408736&sdata=6iIxhZuJpX7n2xR42xj3Bsycwvx8NIcYsvi8RYuw0aI%3D&reserved=0, or mute the threadhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMXHVOfa2UxOqm04GbDxt3Ui5cdXBkphks5uhnN-gaJpZM4S8D3u&data=02%7C01%7C%7C54febb892286444c8fe208d62a3a5f01%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636742827517408736&sdata=A6qLa8KT23EFisy3IoqqYm%2B7Az3wELJ1j6IWCYI%2Bwzs%3D&reserved=0.

LanceMcCarthy commented 6 years ago

It is expected to see the Base64 error upon first launch of the app after the update for many user who have a stored token.

However, close it and then relaunch the app again. On the second launch, you should be automatically logged in.

ReedKimble commented 6 years ago

It does automatically log in – even after resinstalling the login was still automatic.

But no matter how many times I launch the program, I still get the Base64 error.

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: Lance McCarthy notifications@github.com Sent: Thursday, October 4, 2018 6:47:18 PM To: LanceMcCarthy/MvpApi Cc: Reed Kimble; Mention Subject: Re: [LanceMcCarthy/MvpApi] Base64 sometimes fails to convert (#41)

It is expected to see the Base64 error upon first launch of the app after the update for many user who have a stored token.

However, close it and then relaunch the app again. On the second launch, you should be automatically logged in.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FLanceMcCarthy%2FMvpApi%2Fissues%2F41%23issuecomment-427193791&data=02%7C01%7C%7C7e40b462869a4e4ede9008d62a4b56e7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636742900393019978&sdata=49ztOEEFhjSTf9Cc7zqRfSUmkjJ5MLriHVSPFbg%2Fj4M%3D&reserved=0, or mute the threadhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMXHVCSDbL1yRAoCTTesA5EUQJV1qlXqks5uho_2gaJpZM4S8D3u&data=02%7C01%7C%7C7e40b462869a4e4ede9008d62a4b56e7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636742900393019978&sdata=ymZhqnMvpMjJZzTdmyDDYn10SM%2FS0MIaok2R6AXCSLY%3D&reserved=0.

LanceMcCarthy commented 6 years ago

Thanks Reed. I'm going to redesign my error catching logic so that it shows the proper error message. The Base64 message isn't technically correct, the issue is you're getting a 404.

thank you for your patience and cooperation with testing the updates!

LanceMcCarthy commented 5 years ago

@ReedKimble Can you give today's update a try and let me know if you're able to sign in this time? https://www.microsoft.com/store/productid/9NRXNX3WLH77

ReedKimble commented 5 years ago

Here’s what happened:

Just after waking my PC and seeing your email, I got the windows notification that the app had updated. I launched it and was presented with the standard Microsoft login experience. I entered my email and password and the app opened. There were no errors or messages.

However, as you can see in the screenshots attached, everything is blank. I don’t see any contribution info and my profile page is empty.

So that’s where we are at as of today’s update. If there’s anything else you’d like me to try, please let me know.

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: Lance McCarthy notifications@github.com Sent: Wednesday, December 5, 2018 3:17:02 PM To: LanceMcCarthy/MvpApi Cc: Reed Kimble; Mention Subject: Re: [LanceMcCarthy/MvpApi] Base64 sometimes fails to convert (#41)

@ReedKimblehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FReedKimble&data=02%7C01%7C%7C36d6336387d740d73b2b08d65aee9f21%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636796378242924630&sdata=bR023obW0ZGEkSjGh%2BrmwO%2FZgYUICGmEy7gAeLKb8Xw%3D&reserved=0 Can you give today's update a try and let me know if you're able to sign in this time? https://www.microsoft.com/store/productid/9NRXNX3WLH77https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.microsoft.com%2Fstore%2Fproductid%2F9NRXNX3WLH77&data=02%7C01%7C%7C36d6336387d740d73b2b08d65aee9f21%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636796378242924630&sdata=%2Ff76Q2XA6mKaB1sjo8xQ%2FySb%2Bl%2Bo3XQ5YexcIvfBPco%3D&reserved=0

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FLanceMcCarthy%2FMvpApi%2Fissues%2F41%23issuecomment-444630823&data=02%7C01%7C%7C36d6336387d740d73b2b08d65aee9f21%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636796378242924630&sdata=bq3cX30BDTnH3fyioBSCE0gcA%2FSAzwYryvIroX5A1sg%3D&reserved=0, or mute the threadhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMXHVNM1FLI0kY1Uy92MrRebbY-xufbxks5u2Cm-gaJpZM4S8D3u&data=02%7C01%7C%7C36d6336387d740d73b2b08d65aee9f21%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636796378242924630&sdata=kRjPCQWcyhyXHnDopdcJqJjY5Of4fBcpEIu2%2B6NjVrc%3D&reserved=0.

LanceMcCarthy commented 5 years ago

Thank you for taking the time to try it again, I sincerely appreciate it. It looks like nothing I do will get the MVP API to accept the access token that the Live SDK generates for your account.

I did try the new Azure Active Directory v2 "converged" endpoint, which allows me to get an OAuth access token for MSA account, but the API won't accept them either.

I'm sorry for the inconvenience, I'll keep you updated if I get an update form the back-end folks that they've updated the API to accept v2 tokens.

adamj7 commented 4 years ago

I also experienced this authentication issue. I was able to solve it by changing my “Primary Alias” setting to the non MSA email address.

https://account.microsoft.com/profile/ (or https://account.microsoft.com and click on your name in the top left corner) Click "Manage how you sign in to Microsoft" beside your email address. If you don't already have it, add your MVP associated email address to the list Make your MVP associated email the Primary account Alias.

MVPCompanion-Workaround

Load the MVP Companion app again and it should work.

LanceMcCarthy commented 2 years ago

Closing this is as unsolvable via client-side app, you can find a solution if you follow @adamj7's guidance in this reply https://github.com/LanceMcCarthy/MvpApi/issues/41#issuecomment-590924727

Note If you are getting an error after logging in, this was likely due to having more contributions in your MVP history than can be transmitted in a single HTTP response. This has been fixed in 2022.213.1 along with the home page revamp, you can install it now using the beta channel at https://dvlup.blob.core.windows.net/general-app-files/Installers/MvpCompanion/index.html