Esempio n. 1
0
        private async Task Authorize()
        {
            dynamic keys = await GetAppCredentials("Facebook");

            string clientId = keys.client_id;

            IDeviceOAuth2Stepwise auth = new DeviceOAuth(EndPointInfo.Facebook, "public_profile", clientId);
            var info = await auth.StartAuthorization();

            var msg = $"Navigate to {info.VerificationUri} \nEnter this code: {info.UserCode}";

            Notify.Text = msg;

            var token = await auth.WaitForUserConsent(info);

            var defaults = new DynamicRestClientDefaults()
            {
                AuthScheme = "Bearer",
                AuthToken  = token.AccessToken
            };

            dynamic client = new DynamicRestClient("https://graph.facebook.com/v2.3/me", defaults);

            dynamic v = await client.get(fields : "name");

            Notify.Text   = "";
            UserName.Text = v.name;
        }
Esempio n. 2
0
        public async Task FacebookAuthStepwise()
        {
            var keys = TestHelpers.GetAppCredentials("Facebook");
            IDeviceOAuth2Stepwise auth = new DeviceOAuth(EndPointInfo.Facebook, (string)keys.scopes, (string)keys.client_id);

            var info = await auth.StartAuthorization();

            TestHelpers.SpawnBrowser(info.VerificationUri, info.UserCode);

            var token = await auth.WaitForUserConsent(info);

            Assert.IsNotNull(token);
            Assert.IsFalse(string.IsNullOrEmpty(token.AccessToken));
        }