Telerik UI for Windows Phone by Progress

RadCloudLogin allows you to bypass the default Social Login Provider logic and acquire a corresponding access manually. This includes manually opening a corresponding login page in a web browser, requesting the user for permissions and reading the access token from the server response. The following step-by-step guide will explain how to setup an infrastructure to manually acquire an access token from an OAuth 2.0 social login provider.

Note
A manual Access Token retrieval procedure will bypass the automated one.

  1. Define the login providers in your RadCloudLogin instance as described in the Getting started section.
  2. Use the SocialLoginTokenProvider property to define a callback which will be used by RadCloudLogin to read the already acquired access token. This method is internally awaited so that you can easily make asynchronous requests to the remote OAuth 2.0 service provider. The following code sample demonstrates how to do this:

    CopyC#
    public partial class LoginPage : PhoneApplicationPage
    {
        TaskCompletionSource<string> csource = new TaskCompletionSource<string>();
    
        public LoginPage()
        {
            InitializeComponent();
            this.cloudLogin.SocialLoginTokenProvider = this.GetAccessToken;
        }
    
        private async Task<string> GetAccessToken(LoginProvider chosenProvider)
        {
            string response = await this.OpenBrowser("<oauth-provider-uri>");
    
            string accessToken = await this.AcquireAccessToken(response);
    
            return accessToken;
        }
    
        private Task<string> OpenBrowser(string uri)
        {
            // TODO: implement logic which opens a browser and navigates to
            // the URI where user credentials are required.
        }
    
        private Task AcquireAccessToken(string codeResponse)
        {
            // TODO: implement logic which takes the acquired OAuth 2.0 code
            // and requests an access token.
        }
    }

    Note

    The LoginProvider parameter is used to identify which of the available login providers has been chosen by your user. The method returns a string representing the acquired access token. If the return value is null or an empty string no login attempt is made with the initialized Cloud Provider.

    Note

    If the Access Token retrieval is unsuccessful, you can return null or an empty string and RadCloudLogin will bypass the login procedure.