UPDATE:
Windows Phone 8.1 now includes the same Credential Locker as Windows 8 (including roaming). So unless you are targeting prior versions of Windows Phone Silverlight, there’s no need for this port anymore.

One of the most frequent scenario you’ll encounter when developing a mobile app must be storing and retrieving users’ credentials (or tokens) to access some back-end or third-party service in the cloud.

Starting with Windows 8 Store Apps, Microsoft introduced the PasswordVault class that allow developers to store and retrieve those credentials in a secure way:

The PasswordVault class represents a Credential Locker of credentials. The contents of the locker are specific to the app or service. Apps and services don't have access to credentials associated with other apps or services.

So not only are credentials encrypted to avoid tampering, they also cannot be accessed except for the application that stored them (much like the Isolated Storage).

Usage of the PasswordVault class is straight forward:

var vault = new PasswordVault();  
var credential = new PasswordCredential(RESOURCE_NAME, USERNAME, PASSWORD);

vault.Add(credential);  

Apologies! No roaming for Windows Phone.

An added bonus of the original Credential Locker is that the users’ credentials will roam with their Microsoft account to any other trusted machine they use with the same Microsoft account. Sadly, this capability is not currently available in Windows Phone. But to be honest, the original intent of this port was to maximize code reuse, not to bridge the gap in functionality between Windows 8 and Windows Phone (Silverlight).

Hope you find some use for it.

GIST

http://git.io/AZnB2g

Tags

Silverlight , Windows Phone , Credentials

Written by