215
48
www.cod
e
-m
a
g
a
z
in
e
.com
Windows Liv
e
D
e
l
e
g
a
t
e
d APIs
Well defi ned architectural patterns will be de-
2.
fi ned to guide application development.
Tools will emerge to automate some of the
3.
code generation (see next section).
A
D
O
.N
E
T
D
ata Services (aka Astoria)
At the MIX07 conference in Las Vegas, a new tech-
nology codenamed Astoria was announced. Astoria
has since been named ADO.NET Data Services and
is currently available as a download as a pre-release
(CTP) for Visual Studio 2008 users in the ASP.NET
3.5 Extensions pack.
The ADO.NET Data Services consists of librar-
ies for creating and consuming data services over
HTTP. These ADO.NET Data Services can present
CRUD operations, which can be invoked through
the use of the HTTP verbs (GET, PUT, POST, DE-
LETE). Does this sound familiar yet
?
ADO.NET Data Services are designed to work with
standard formats such as JSON and AtomPub. This
is really l
u
c
k
y for developers who want to use the
new Windows Live AtomPub services!
However, there is more goodness to be harvested
from the ADO.NET Data Services, as they provide
a mechanism for modeling the data into objects.
These objects are instances of entities and you can
use the ADO.NET Data Service to represent the
data as entities, and also the relationships between
the entities, as defi ned in the service schemas.
For developers consuming services, this means
that they can interact with Window Live AtomPub
services in terms of .NET objects that can be que-
ried, modifi ed, and sent back to the service. This
is a great, natural way of interacting with services
from the .NET environment. Since it is all AtomPub
under the covers, openness and interoperability are
not compromised.
As a related note, developers wanting to create
services that follow the same HTTP interface pat-
tern as Windows Live AtomPub services can use
ADO.NET Data Services on the server to easily
do that.
Microsoft,
D
o It for Me
By providing the Windows Live Service offerings
in the AtomPub open standard, Microsoft has en-
abled all developers to access the same services in a
uniform way. As an ASP.NET developer, you might
not care about those
other
programmers but having
a well defi ned and open standard way of access-
ing the data benefi ts you as well. In an ASP.NET
server-side development world, much of the code
needed to access these AtomPub services can be in
a template and reused.
The ADO.NET Data Services provides this templat-
ing technology. An ASP.NET AJAX library abstracts
in a short time frame, so your application may need
to use the refresh token to request a new delegation
token. Fig
u
r
e
1 shows the data fl ow in the delegat-
ed authentication process.
If your application knows about a user, for example
you use the Live ID Web authentication model to
manage logged in users, then you probably want
to store the consent token against the user ID. The
best approach for this would be to create a new data
table in your application data-
base to maintain the refresh to-
ken and services (with expira-
tion dates) for each user.
One more thing that you
should take into consideration
is that the expiration dates you
have stored for a user may no
longer be valid. At any time a
user can change the permis-
sions they have granted to ap-
plications. This means that the
expiration dates should be used
as a guide for your application to determine if you
need to present the consent screen to the user again
and request a new consent token. If the user has re-
voked the permission for your application to access
their data, your application will receive an unau-
thorized access response. Your application needs to
gracefully handle an unauthorized access response;
your application could reroute the user to the con-
sent screen, but it would be smarter to indicate to
the user why they are being asked for permission
again.
E
veryth
i
ng as an Atom
The Atom Publishing Protocol (or AtomPub as
it’s often called) defi nes a simple protocol for per-
forming CRUD (Create, Read, Update, and Delete)
operations on data over HTTP. Over the coming
months, most of the Windows Live Services will
provide offerings that conform to the AtomPub
standards. This is a fantastic move towards stan-
dardization of the Windows Live Services APIs.
In the last few years the APIs emerging from the
various Windows Live Services have been varied
and numerous. Each product group within Micro-
soft created their own API set, some were REST
based, some were SOAP, others were WebDav.
Standardizing on a single technology to access the
Windows Live Services will make our lives as de-
velopers easier.
The new AtomPub services will be available for ac-
cess through the delegated authentication mecha-
nism described in the previous section. Combin-
ing these two technologies to create a well defi ned
mechanism for accessing, authenticating, and work-
ing with the Windows Live Services has the follow-
ing implications:
Applications can reuse the authentication
1.
code across multiple services.
If the serv
i
ce offered
requ
i
res that you
i
dent
i
fy your
app
l
i
cat
i
on w
i
th an
app
l
i
cat
i
on
i
dent
i
fi er,
you w
i
l
l
need to obta
i
n an
app
l
i
cat
i
on I
D
from the W
i
ndows
L
i
ve M
i
crosoft
S
erv
i
ce Manager