GenesysStack.com
RSS

Blog posts of '2015' 'August'

Microsoft Account Logon for Windows Universal (8, 8.1, 10) Apps

Microsoft Account Logon for Windows Universal (8, 8.1, 10) Apps

Introduction

I spent way too much time figuring out something so simple: How do I auto-logon my Windows 8/Windows Phone 8 app?

Call it what you want, single sign-on (SSO), automatic logon, unified logon...the point is the same. A well-written native app doesn't bother the user to logon or register unless necessary. Extra hassles for the user, extra dev time, extra code to maintain. Why not let the device automatically log on the user?

The (confusing) Journey

So I started researching for my Windows 8 app (now with Windows Universal, the same app will run on Windows Phone 8 also).

My career is in the mid-sized company world, which tends to roll-your-own authentication/registration. So I had to catch up with all the new cool SSO services out there. Wanting to go Microsoft, I found that there were plenty of services: Windows Live Account Services, Azure ACS, Azure AD, Microsoft Account, etc. In short, Azure AD is the newest service that supports cross-platform devices for most current Auth providers (Microsoft, Facebook, Google, LinkedIn, etc.)

Azure AD sounded pretty good, but being a solo cowboy startup, I didnt have much time for research. So I started researching Azure AD, and it seemed simple! But after fumbling with getting a sample app working with my Azure account, I decided to switch to the Windows 8-only method...Microsoft Account logon. Besides, Azure would require a SSO web service so that all of my web sites and native apps would work. I didn't want to write a SSO provider just yet, I want to get my app off the ground quickly.

Too much research time spent already, time to switch gears to Microsoft Account...I'll port to Azure AD later.

I found a PERFECT sample here. Download the app, run the app, watch it auto-logon. Well the sample app stopped the auto-logon to have a Sign In button, but you get the picture.

Copied the code to my brand new Windows Universal template, run the app, and an error: {"The application requesting authentication tokens is either disabled or incorrectly configured. (Exception from HRESULT: 0x80860003)"}

The problem was that the app needed to be known to my Microsoft Developer account. But nowhere in any documentation did I see the critical step that accomplished this. Minutes turned into hours, and I just so happened to stumble on the solution... one click of a menu in Visual Studio 2013. Thats all it took to get it working, jeez.

Just Tell Me the Answer!

Ok, so here is the answer.

  • Download the Microsoft Account Sample here
  • Create your app, and copy all code from Scenario01_DelegationToken.xaml.cs. Just comment out all of the errors, they are all UI controls that aren't needed. Remember to make SignInButton_Click public so you can call it directly.
  • At this point, running your app will fail...need to link it to your developer account.
  • Create a Microsoft Developer account here.
  • Go to your Dashboard here and register your app, Step 1 (Name your App) is all that is required.
  • Now the trick: Right-click your Project in Visual Studio 2013, click Store, and click Associate App with the Store.

Blog-AssociateStore

Guess what? It works. Hope this helps somebody!

Rules to Code By

Be a businessperson first, coder second

Learn business models. Observe those who are successful. Speak, act and dress as a business person. If you think business first, programming second...you will be much more valuable and your products will show your value.

Code for the rules, not for the exceptions

Learn the domain, and apply it to your product. Avoid making the car that can fly, and be a submarine, and fly to the moon...most likely that is not what Ford wants. Ford wants a solid car that fits their customer's needs.

Dropping all code that handles for the thousands of 'what ifs' makes your code cleaner, faster and more maintainable.

Keep pressing buttons

To create a product, keep pressing buttons. All of the planning, support teams and innovation is useless if somebody does not press buttons on a keyboard.

Feeling overwhelmed with your project? Keep pressing buttons. Feeling lazy and want to surf the net? Keep pressing buttons. Some team members talking it up in the hallway? Keep pressing buttons. You will be quickly known as the fastest programmer on the team.

Fix bugs through good design, not through coding

Eliminate hoards of bugs before they exist by designing the product well. Design your product with simplicity in mind, and effective implementation practices. Encapsulation for reusability, decoupling for 'divide and conquer' creation and maintainability, simple readable code...bugs will drop off all by themselves.

Favor being consistently wrong over being inconsistently right

Product components that fail 100% of the time are much easier to detect, diagnose and fix than components that fail 10% of the time. Be consistent, even if you eventually find that you were wrong.

Do your due diligence to investigate anything new...and then confidently implement globally. If it works, it will work everywhere. If it fails, it will be very easy to rip out and try again.

Software is built like any other product on the planet

Just because software is buried inside of a computer does not mean that it is extraterrestrial. Building software follows the same process and incurs the same problems as building a car, house or a pen.

Try building a house without knowing your customer (requirements), without correct blueprints (design), without correct workmanship (coding & standards) and without correct inspection (QA). Your house will be a three-walled crooked office building that easily catches fire...when all your customer wanted was a safe three-bedroom house.

Insanity: doing the same thing over and over again and expecting different results

Who knew that Albert Einstein understood people, the SDLC and departmental organization?

Telling a coder not to be late and threatening termination is not changing anything. The next project will be just as late as the last. Rather the person is broken, the SDLC is broken or the department organization is broken. Find out which, correct it and move on.

A Prototype is guaranteed to go to production as your 1.0

Developing a prototype proof of concept only works if your company is willing to pay twice for the same thing. Your prototype is heading straight for your production servers and marketing is already sending the announcement to every email address on file. Bet on it.

Interruptions kill timelines

An army is 95% support staff, 5% warriors, a software department is the same. A developer needs to work uninterrupted for hours at a time. A support staff of business analysts, customer/technical support, QA and training reduces interruptions.

Hire the support people. Draw clear job responsibilities. Protect your development team and you will not be paying a programmer $100,000 per/year to do a $50,000 per/year level 1 tech support job.

Pay me now, or pay me later. You will pay. Late projects, upset coders...or hire the right people for the right job and deliver on time.

Daily overtime does more damage than good

Be a hero that swoops in to save a company or employee in a bind, not a martyr. Occasional overtime, no problem. Consistent overtime, problem.

Imagine an employee that works 2 hours more every day. That employee quits, or worse, dies of a heart attack. Now you have to hire 1.25 employees to replace that person. You have to pay 125% to train that new employee. You lose 25% more undocumented knowledge that will never come back.

Show up on time, work hard and efficiently, and go home. Your company, your family, and your doctor will thank you.

Take care of yourself, your company is paying the bill

No boss likes to see a tired, hung-over, overweight, emotionally unstable employee.

Dress well. Keep your health up. Take time for recreation to clear your mind. Have hobbies. Keep a positive outlook on life. Enjoy! Your company is paying for it.