Skip to main content

Microsoft Live - Live Connect

Windows LIVE series:

Si am ajuns la lucruri mai interesante. O sa incep azi sa povestim despre Live Connect. Ce putem sa facem cu Live Connect? Un user conectat la aplicatia noastra se poate conecta la email, SkyDrive, messeaging sau orice alt serviciu folosind un Live ID.
Cum il folosim? Partea buna in toata nebunia asta este ca API-ul de Live Connect este conform standardului OAuth 2.0 si suporta atat JSON cat si protocolul XMPP. Acesta poate sa fie integrat in orice fel de aplicatie, indiferent de limbaj sau platforma.
Daca e prima data cand auziti de XMPP, trebuie sa stiti ca acesta este un standard de comunicare pentru aplicatiile de chat, care permite ca sa ne integram aplicatiile proprii de chat cu Messenger-ul de la Microsoft faca nici o problema.
In urmatorul exemplu o sa vedem ce trebuie sa facem ca un utilizator sa se autentifice prin apeluri de tip REST:
- redirectam userul spre urmatoarea pagina, unde reprezinta id-ul pe care l-am primit cand ne-am inregistrat aplicatia, iar reprezinta url spre care userul o sa fie redirectionat in momentul in care procesul de autentificare s-a terminat cu succes. Despre parametrul vrea sa vorbim putin mai tarziu
https://oauth.live.com/authorize?client_id=<client_id>&scope=<scope>&response_type=code&redirect_uri=<redirect_url>
- dupa ce autentificare sa terminat, userul este redirectionat spre . In url o sa avem un parametru cu numele de 'code', pe baza caruia, putem sa obtinem token-ul de acces a userului. Folosind acest cod putem sa accesam orice serviciu integrat cu Live Connect. Mai jos gasiti modul in care serverul o sa ne apeleze aplicatia:
<redirect_url>?code=<o_cheie_unica>
- token-ul de acces a userului, de care avem nevoie ca sa accesam serviciile dorite se obtine apeland urmatorul url:
https://oauth.live.com/token?client_id=<client_id>&redirect_uri=<redirect_url>&client_secret=<client_secret_key>&code=<code>&grant_type=authorization_code

  • client_secret_key - reprezinta cheia unica pe care am obtinut-o cand am inregistrat aplicatia
  • authorization_code - specifica modul prin care vrem sa obtinem token-ul clientului. In cazul nostru pe baza codului pe care l-am obtinut la pasul precedent
Raspunsul care o sa ne vina in urma ultimului apel o sa contina 5 elemente:
  1. access_token - token-ul de acces la servicii, pe care o sa il folosim cand vrem sa accesam un serviciu
  2. authentification_token - token-ul de autentificare
  3. scope - pentru ce servicii poate sa fie folosit token-ul
  4. token_type - tipul de token obtinut( de obicei o sa fie 'bearer')
  5. expires_in - durata de timp cand token-ul de acces poate sa fie folosit( valoarea este exprimata in secunde).
Mai jos gasiti un exemplu de raspuns in format JSON, pe care il primim in urma apelului:
{    "access_token" : "ExxXCSFCCWEECECE...AA==",    "authentication_token" : "423423-423424-2342342";    "expires_in" : 3600,    "scope" : "wl.signin wl.basic wl.calendars",    "token_type" : "bearer"}
Intr-un alt post o sa revin cu o descriere despre cum consumam serviciile integrate cu Live ID. Ce trebuie sa tinem minte este ca ce trebuie sa facem este sa apelam un url, cu anumiti parametrii in care sa includem si token-ul de acces.
Am ramas dator cu o explicatie. Ce este un SCOPE? Actiune prin care cerem permisiune unui user sa accesam unu sau mai multe servicii in numele acestuia.
Exista trei tipuri de scope:
  • core - sunt serviciile de baza precum: conectare la Live Connect, lista de contacte, acces offline la date, fara ca userul sa mai fie nevoit sa se autentifice in aplicatia noastra
  • extended - cateva servicii auxiliare, care completeaza functionalitatiile de baza( calendar, poze, skydrive, messeger, etc)
  • developer - servici create de catre alti dezvoltatori, care sunt integrate cu Live Connect( orice persoana poate sa scrie o aplicatie si sa fie accesibila de catre orice persoana prin intermediul Live Connect)
Pentru o lista detaliata puteti accesa urmatorul link http://msdn.microsoft.com/en-us/library/hh243646.aspx.

Comments

Popular posts from this blog

Windows Docker Containers can make WIN32 API calls, use COM and ASP.NET WebForms

After the last post , I received two interesting questions related to Docker and Windows. People were interested if we do Win32 API calls from a Docker container and if there is support for COM. WIN32 Support To test calls to WIN32 API, let’s try to populate SYSTEM_INFO class. [StructLayout(LayoutKind.Sequential)] public struct SYSTEM_INFO { public uint dwOemId; public uint dwPageSize; public uint lpMinimumApplicationAddress; public uint lpMaximumApplicationAddress; public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public uint dwProcessorLevel; public uint dwProcessorRevision; } ... [DllImport("kernel32")] static extern void GetSystemInfo(ref SYSTEM_INFO pSI); ... SYSTEM_INFO pSI = new SYSTEM_INFO(

Azure AD and AWS Cognito side-by-side

In the last few weeks, I was involved in multiple opportunities on Microsoft Azure and Amazon, where we had to analyse AWS Cognito, Azure AD and other solutions that are available on the market. I decided to consolidate in one post all features and differences that I identified for both of them that we should need to take into account. Take into account that Azure AD is an identity and access management services well integrated with Microsoft stack. In comparison, AWS Cognito is just a user sign-up, sign-in and access control and nothing more. The focus is not on the main features, is more on small things that can make a difference when you want to decide where we want to store and manage our users.  This information might be useful in the future when we need to decide where we want to keep and manage our users.  Feature Azure AD (B2C, B2C) AWS Cognito Access token lifetime Default 1h – the value is configurable 1h – cannot be modified

What to do when you hit the throughput limits of Azure Storage (Blobs)

In this post we will talk about how we can detect when we hit a throughput limit of Azure Storage and what we can do in that moment. Context If we take a look on Scalability Targets of Azure Storage ( https://azure.microsoft.com/en-us/documentation/articles/storage-scalability-targets/ ) we will observe that the limits are prety high. But, based on our business logic we can end up at this limits. If you create a system that is hitted by a high number of device, you can hit easily the total number of requests rate that can be done on a Storage Account. This limits on Azure is 20.000 IOPS (entities or messages per second) where (and this is very important) the size of the request is 1KB. Normally, if you make a load tests where 20.000 clients will hit different blobs storages from the same Azure Storage Account, this limits can be reached. How we can detect this problem? From client, we can detect that this limits was reached based on the HTTP error code that is returned by HTTP