private async void OnFacebookClick(object sender, RoutedEventArgs e) { var credentials = _settings .GetClientCredentials <Facebook, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Facebook>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <FacebookEvent>() .GetCredentialsAsync() .ConfigureAwait(false); WriteToTextbox($"AccessToken:{token.AccessToken}"); }
public async void CanGetValidAccessTokenFromTwitter() { var credentials = _settings .GetClientCredentials <Twitter, OAuth1Credentials>(); var token = await new OAuth1App <Twitter>( credentials.ConsumerKey, credentials.ConsumerSecret, credentials.CallbackUrl) .GetCredentialsAsync() .ConfigureAwait(false); Assert.True(IsValidOAuth1Token(token, true)); //Assert.Equal(1, token.AdditionalParameters.Count); //screen_name if (TestSettings.ShouldPersistCredentials) { TestSettings.WriteCredentials <Twitter>(token); } }
public override void ViewDidLoad() { base.ViewDidLoad(); var settings = new CredentialApplicationSettings(); BrowserToggle.TouchUpInside += (sender, args) => { _browserType = BrowserToggle.On ? AuthenticationInterfaceEnum.Embedded : AuthenticationInterfaceEnum.Dedicated; _callbackType = BrowserToggle.On ? CallbackTypeEnum.Localhost : CallbackTypeEnum.Protocol; }; FacebookAuth.TouchUpInside += async(sender, e) => { var credentials = settings .GetClientCredentials <Facebook, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Facebook>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <FacebookEvent>() .GetCredentialsAsync() .ConfigureAwait(false); WriteResultToTextView("Access Token:" + token.AccessToken); }; TwitterAuth.TouchUpInside += async(sender, e) => { var credentials = settings .GetClientCredentials <Twitter, OAuth1Credentials>(_callbackType); var token = await new OAuth1App <Twitter>( credentials.ConsumerKey, credentials.ConsumerSecret, credentials.CallbackUrl, browserType: _browserType) .GetCredentialsAsync() .ConfigureAwait(false); WriteResultToTextView("OAuth Secret: " + token.OAuthSecret + "\nOAuth Token: " + token.OAuthToken); }; FatsecretAuth.TouchUpInside += async(sender, e) => { var credentials = settings .GetClientCredentials <Fatsecret, OAuth1Credentials>(_callbackType); var token = await new OAuth1App <Fatsecret>( credentials.ConsumerKey, credentials.ConsumerSecret, credentials.CallbackUrl, browserType: _browserType) .GetCredentialsAsync() .ConfigureAwait(false); WriteResultToTextView("OAuth Secret: " + token.OAuthSecret + "\nOAuth Token: " + token.OAuthToken); }; WithingsAuth.TouchUpInside += async(sender, args) => { var credentials = settings .GetClientCredentials <Withings, OAuth1Credentials>(_callbackType); var token = await new OAuth1App <Withings>( credentials.ConsumerKey, credentials.ConsumerSecret, credentials.CallbackUrl, browserType: _browserType) .GetCredentialsAsync() .ConfigureAwait(false); WriteResultToTextView("OAuth Secret: " + token.OAuthSecret + "\nOAuth Token: " + token.OAuthToken); }; SpotifyAuth.TouchUpInside += async(sender, e) => { var credentials = settings .GetClientCredentials <Spotify, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Spotify>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <SpotifySavedTrack>() .GetCredentialsAsync() .ConfigureAwait(false); WriteResultToTextView("Access Token:" + token.AccessToken); }; GoogleAuth.TouchUpInside += async(sender, e) => { var credentials = settings .GetClientCredentials <Google, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Google>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <GoogleGmailMetadata>() .GetCredentialsAsync() .ConfigureAwait(false); WriteResultToTextView("Access Token:" + token.AccessToken); }; FitbitAuth.TouchUpInside += async(sender, e) => { var credentials = settings .GetClientCredentials <Fitbit, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Fitbit>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <FitbitProfile>() .GetCredentialsAsync() .ConfigureAwait(false); WriteResultToTextView("Access Token:" + token.AccessToken); }; RunkeeperAuth.TouchUpInside += async(sender, e) => { var credentials = settings .GetClientCredentials <Runkeeper, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Runkeeper>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <RunkeeperFitnessActivity>() .GetCredentialsAsync() .ConfigureAwait(false); WriteResultToTextView("Access Token:" + token.AccessToken); }; FoursquareAuth.TouchUpInside += async(sender, e) => { var credentials = settings .GetClientCredentials <Foursquare, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Foursquare>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .GetCredentialsAsync() .ConfigureAwait(false); WriteResultToTextView("Access Token:" + token.AccessToken); }; RescuetimeAuth.TouchUpInside += async(sender, e) => { var credentials = settings .GetClientCredentials <Rescuetime, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Rescuetime>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <RescuetimeAnalyticData>() .GetCredentialsAsync() .ConfigureAwait(false); WriteResultToTextView("Access Token:" + token.AccessToken); }; LinkedinAuth.TouchUpInside += async(sender, e) => { var credentials = settings .GetClientCredentials <LinkedIn, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <LinkedIn>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <LinkedinPersonal>() .GetCredentialsAsync() .ConfigureAwait(false); WriteResultToTextView("Access Token:" + token.AccessToken); }; MioAuth.TouchUpInside += async(sender, args) => { var auth = new BluetoothApp <Mioalpha>(); var credentials = await auth.GetBluetoothCredentialsAsync() .ConfigureAwait(false); WriteResultToTextView("Device Address: " + credentials.DeviceAddress); var requester = new BluetoothRequester(); var result = await requester .MakeBluetoothRequestAsync <MioHeartRate>(credentials) .ConfigureAwait(false); WriteResultToTextView("Heart rate: " + result.Reading); }; GPS.TouchUpInside += async(sender, args) => { var result = await new GPSRequester() .MakeGPSRequestAsync() .ConfigureAwait(false); WriteResultToTextView($"Latitude: {result.Latitude}, Longitude: {result.Longitude}, Speed: {result.Speed}"); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); var settings = new CredentialApplicationSettings(); SetContentView(Resource.Layout.Main); var toggleButton = FindViewById <ToggleButton>(Resource.Id.browserToggleButton); toggleButton.Click += (o, e) => { _browserType = toggleButton.Checked ? AuthenticationInterfaceEnum.Dedicated : AuthenticationInterfaceEnum.Embedded; _callbackType = toggleButton.Checked ? CallbackTypeEnum.Protocol : CallbackTypeEnum.Localhost; }; FindViewById <Button>(Resource.Id.facebookAuth).Click += async(sender, args) => { var credentials = settings .GetClientCredentials <Facebook, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Facebook>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <FacebookEvent>() .GetCredentialsAsync() .ConfigureAwait(false); WriteCredentials(token); }; FindViewById <Button>(Resource.Id.twitterAuth).Click += async(sender, args) => { var credentials = settings .GetClientCredentials <Twitter, OAuth1Credentials>(_callbackType); var token = await new OAuth1App <Twitter>( credentials.ConsumerKey, credentials.ConsumerSecret, credentials.CallbackUrl, browserType: _browserType) .GetCredentialsAsync() .ConfigureAwait(false); WriteCredentials(token); }; FindViewById <Button>(Resource.Id.fatsecretAuth).Click += async(sender, args) => { var credentials = settings .GetClientCredentials <Fatsecret, OAuth1Credentials>(_callbackType); var token = await new OAuth1App <Fatsecret>( credentials.ConsumerKey, credentials.ConsumerSecret, credentials.CallbackUrl, browserType: _browserType) .GetCredentialsAsync() .ConfigureAwait(false); WriteCredentials(token); }; FindViewById <Button>(Resource.Id.withings).Click += async(sender, args) => { var credentials = settings .GetClientCredentials <Withings, OAuth1Credentials>(_callbackType); var token = await new OAuth1App <Withings>( credentials.ConsumerKey, credentials.ConsumerSecret, credentials.CallbackUrl, browserType: _browserType) .GetCredentialsAsync() .ConfigureAwait(false); WriteCredentials(token); }; FindViewById <Button>(Resource.Id.fitbitAuth).Click += async(sender, args) => { var credentials = settings .GetClientCredentials <Fitbit, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Fitbit>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <FitbitProfile>() .GetCredentialsAsync() .ConfigureAwait(false); WriteCredentials(token); }; FindViewById <Button>(Resource.Id.foursquareAuth).Click += async(sender, args) => { var credentials = settings .GetClientCredentials <Foursquare, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Foursquare>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .GetCredentialsAsync() .ConfigureAwait(false); WriteCredentials(token); }; FindViewById <Button>(Resource.Id.googleAuth).Click += async(sender, args) => { var credentials = settings .GetClientCredentials <Google, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Google>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <GoogleGmailMetadata>() .AddScope <GoogleGmail>() .GetCredentialsAsync() .ConfigureAwait(false); WriteCredentials(token); }; FindViewById <Button>(Resource.Id.linkedinAuth).Click += async(sender, args) => { var credentials = settings .GetClientCredentials <LinkedIn, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <LinkedIn>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <LinkedinPersonal>() .GetCredentialsAsync() .ConfigureAwait(false); WriteCredentials(token); }; FindViewById <Button>(Resource.Id.rescuetimeAuth).Click += async(sender, args) => { var credentials = settings .GetClientCredentials <Rescuetime, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Rescuetime>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <RescuetimeAnalyticData>() .GetCredentialsAsync() .ConfigureAwait(false); WriteCredentials(token); }; FindViewById <Button>(Resource.Id.spotifyAuth).Click += async(sender, args) => { var credentials = settings .GetClientCredentials <Spotify, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Spotify>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <SpotifySavedTrack>() .GetCredentialsAsync() .ConfigureAwait(false); WriteCredentials(token); }; FindViewById <Button>(Resource.Id.runkeeperAuth).Click += async(sender, args) => { var credentials = settings .GetClientCredentials <Runkeeper, OAuth2Credentials>(_callbackType); var token = await new OAuth2App <Runkeeper>( credentials.ClientId, credentials.ClientSecret, credentials.CallbackUrl, browserType: _browserType) .AddScope <RunkeeperFitnessActivity>() .GetCredentialsAsync() .ConfigureAwait(false); WriteCredentials(token); }; FindViewById <Button>(Resource.Id.mioalphaAuth).Click += async(sender, args) => { var credentials = await new BluetoothApp <Mioalpha>() .GetBluetoothCredentialsAsync() .ConfigureAwait(false); WriteResultToTextView("Device Address: " + credentials.DeviceAddress); var result = await new BluetoothRequester() .MakeBluetoothRequestAsync <MioHeartRate>(credentials) .ConfigureAwait(false); WriteResultToTextView("Heart rate: " + result.Reading); }; FindViewById <Button>(Resource.Id.gps).Click += async(sender, args) => { var result = await new GPSRequester() .MakeGPSRequestAsync() .ConfigureAwait(false); WriteResultToTextView( $"Latitude: {result.Latitude}, Longitude: {result.Longitude}, Speed: {result.Speed}"); }; FindViewById <Button>(Resource.Id.sms).Click += async(sender, args) => { var filterDate = new DateTime(2016, 7, 21, 0, 0, 0); var results = await new SMSRequester() .MakeSMSRequestAsync(filterDate) .ConfigureAwait(false); var resultsString = string.Empty; foreach (var result in results) { resultsString += $"Address: {result.Address}, Header: {result.Subject}, Body: {result.Body}\n"; } WriteResultToTextView(resultsString); }; }