private void Initialize() { try { Console.WriteLine("DropboxCoreService - Initialize - Initializing service..."); var diskToken = LoadTokenFromDisk(); var oauthAccessToken = new OAuthToken(diskToken.Value, diskToken.Secret); _dropboxServiceProvider = new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder); _dropbox = _dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret); //dropbox.Locale = CultureInfo.CurrentUICulture.IetfLanguageTag; HasLinkedAccount = true; Console.WriteLine("DropboxCoreService - Initialize - Finished initializing service!"); } catch (AggregateException ae) { HasLinkedAccount = false; ae.Handle(ex => { if (ex is DropboxApiException) { Console.WriteLine("DropboxCoreService - Initialize - Exception: {0}", ex); return true; } // Ignore exceptions; if we cannot login on initialize, the user will have to relink the app later. // The UI should check the HasLinkedAccount property to see if Dropbox is available. return true; }); } catch (Exception ex) { // Ignore exceptions (see previous comment) } }
private DropboxImageUploader() { this.dropboxServiceProvider = new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.Full); this.oauthAccessToken = new OAuthToken(OauthAccessTokenValue, OauthAccessTokenSecret); // this.oauthAccessToken = this.LoadOAuthToken(); this.client = new WebClient(); this.dropbox = this.dropboxServiceProvider.GetApi(this.oauthAccessToken.Value, this.oauthAccessToken.Secret); }
public static async Task<ObservableCollection<MeetupEvent>> GetMeetupsFor(string uservar, string toggle, OAuthToken token) { var meetupServiceProvider = new MeetupServiceProvider(MeetupApiKey, MeetupSecretKey); var meetup = meetupServiceProvider.GetApi(token.Value, token.Secret); string json; if (toggle == "Meetup Group") { json = await meetup.RestOperations.GetForObjectAsync<string>($"https://api.meetup.com/2/events?offset=0&format=json&limited_events=False&group_urlname={uservar}&photo-host=public&page=20&fields=&order=time&desc=false&status=upcoming&sig_id=182757480&sig=52d73860784c45691862aa492856c26332cd67af"); } else { json = await meetup.RestOperations.GetForObjectAsync<string>($"https://api.meetup.com/2/concierge?zip={uservar}&offset=0&format=json&photo-host=public&page=500&sig_id=182757480&sig=199b985b4335074f44fbe4697f34f1ff7026bf50"); } EventReturn j = JsonConvert.DeserializeObject<EventReturn>(json); /* ObservableCollection<string> MEvents = new ObservableCollection<string>(); foreach (var i in j.results) { MEvents.Add($"\nName: {i.name}\nStatus: {i.status}\nTime: {i.time}"); }*/ ObservableCollection<MeetupEvent> MEvents = new ObservableCollection<MeetupEvent>(); foreach (var i in j.results) { MEvents.Add(i); } return MEvents; }
private DropboxServiceProvider Initialize(string key, string secret) { DropboxServiceProvider dropboxServiceProvider = new DropboxServiceProvider(key, secret, AccessLevel.AppFolder); this.oauthAccessToken = this.LoadOAuthToken(); return dropboxServiceProvider; }
public static async Task<OAuthToken> authenticate2(OAuthToken tok, string pin) { var requestToken = new AuthorizedRequestToken(tok, pin); var meetupServiceProvider = new MeetupServiceProvider(MeetupApiKey, MeetupSecretKey); var oathAccessToken = meetupServiceProvider.OAuthOperations.ExchangeForAccessTokenAsync(requestToken, null).Result; return oathAccessToken; }
private IDropbox Authenticate(DropboxServiceProvider dropboxServiceProvider, DropboxProvider provider, string OAuthTokenFileName) { OAuthToken oauthAccessToken = new OAuthToken("ng8ydj1aoljno9fk", "fyqdn9sv71fn8on"); // Login in Dropbox IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret); return dropbox; }
private static OAuthToken LoadOAuthToken() { using (var db = new OfferWorldContext()) { var data = db.DropboxAuthentication.First(); OAuthToken oauthAccessToken = new OAuthToken("d2576clemzwat0gv", "s066q2wjnpct8nx"); return oauthAccessToken; } }
private DropboxServiceProvider Initialize(string key, string secret) { DropboxServiceProvider dropboxServiceProvider = new DropboxServiceProvider(key, secret, AccessLevel.AppFolder); if (!File.Exists(OAuthTokenFileName)) { this.AuthorizeAppOAuth(dropboxServiceProvider); } this.oauthAccessToken = this.LoadOAuthToken(); return dropboxServiceProvider; }
private static IDropbox CreatingFile() { DropboxServiceProvider dropboxServiceProvider = new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder); // Authenticate the application (if not authenticated) and load the OAuth token OAuthToken oauthAccessToken = new OAuthToken("jxfhttvyu86uiy7r", "in5chjjhszsdiem"); // Login in Dropbox IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret); return dropbox; }
protected void Page_Load(object sender, EventArgs e) { if ((Request.Cookies["requestTokenValue"] == null) || (Request.Cookies["requestTokenSecret"] == null)) { DropboxAuth(); } if ((Request.Cookies["TokenValue"] == null) || (Request.Cookies["TokenSecret"] == null)) { OAuthToken requestToken = new OAuthToken(Request.Cookies["requestTokenValue"].Value, Request.Cookies["requestTokenSecret"].Value); AuthorizedRequestToken authorizedRequestToken = new AuthorizedRequestToken(requestToken, null); OAuthToken token = dropboxServiceProvider.OAuthOperations.ExchangeForAccessTokenAsync(authorizedRequestToken, null).Result; Response.Cookies["TokenValue"].Value = token.Value; Response.Cookies["TokenSecret"].Value = token.Secret; } }
public void PostFile(FileModel file) { DropboxServiceProvider dropboxServiceProvider = new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder); OAuthToken oauthAccessToken = new OAuthToken("9gyo6l0xq3l7kdd0", "ly7ayinrqbocfy8"); // Login in Dropbox IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret); // Create new folder string newFolderName = "New_Folder_" + DateTime.Now.Ticks; Entry createFolderEntry = dropbox.CreateFolderAsync(newFolderName).Result; // Upload a file IResource fileResource = new FileResource(file.Path + "/" + file.Name); Entry uploadFileEntry = dropbox.UploadFileAsync(fileResource, "/" + newFolderName + "/" + file.Name).Result; // Share a file DropboxLink sharedUrl = dropbox.GetMediaLinkAsync(uploadFileEntry.Path).Result; // Update database Message newMessage = new Message() { Content = sharedUrl.Url.ToString(), SendTime = DateTime.Now, User = (from users in db.Users where users.UserId == file.UserId select users).FirstOrDefault(), UserId = file.UserId, RecieverId = file.RecieverId }; if (file.IsProfilePic) { User currentUser = (from users in db.Users where users.UserId == file.UserId select users).FirstOrDefault(); currentUser.ProfilePicUrl = sharedUrl.Url.ToString(); } db.Messages.Add(newMessage); db.SaveChanges(); }
private const string OAuthTokenFileName = "OAuthTokenFileName.txt"; //Not Used #endregion Fields #region Methods public static string UploadProfilePicToDropBox(string filePath, string fileName) { DropboxServiceProvider dropboxServiceProvider = new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder); // Authenticate the application (if not authenticated) and load the OAuth token //if (!File.Exists(OAuthTokenFileName)) //{ //ImageGallery.Persisters.DropboxManager.AuthorizeAppOAuth(dropboxServiceProvider); //} OAuthToken oauthAccessToken = new OAuthToken("1ni4swcml3tpqmyo", "7v3zjtj3e42f9bt"); // Login in Dropbox IDropbox dropbox = dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret); //// Display user name (from his profile) //DropboxProfile profile = dropbox.GetUserProfileAsync().Result; //Console.WriteLine("Hi " + profile.DisplayName + "!"); // Create new folder string newFolderName = DateTime.Now.Ticks.ToString(); //Entry createFolderEntry = dropbox.CreateFolderAsync(newFolderName).Result; //Console.WriteLine("Created folder: {0}", createFolderEntry.Path); // Upload a file Entry uploadFileEntry = dropbox.UploadFileAsync( new FileResource(filePath), "/" + newFolderName + "_" + fileName.Substring(1, fileName.Length - 2)).Result; //Console.WriteLine("Uploaded a file: {0}", uploadFileEntry.Path); // Share a file DropboxLink sharedUrl = dropbox.GetMediaLinkAsync(uploadFileEntry.Path).Result; //Process.Start(sharedUrl.Url); char ch = '\"'; string urlToDropbox = sharedUrl.Url.TrimEnd(new char[] { '_', ' ' }); return urlToDropbox; }
private static OAuthToken LoadOAuthToken() { string[] lines = File.ReadAllLines(OAuthTokenFileName); OAuthToken oauthAccessToken = new OAuthToken(lines[0], lines[1]); return oauthAccessToken; }
private OAuthToken LoadOAuthToken() { OAuthToken oauthAccessToken = new OAuthToken("hsmlwuul3nbd72go", "z183wdbxk9dj49i"); return oauthAccessToken; }
/// <summary> /// Creates an authorized request token. /// </summary> /// <param name="requestToken">The request token object.</param> /// <param name="verifier">The access token verifier.</param> public AuthorizedRequestToken(OAuthToken requestToken, string verifier) { this.requestToken = requestToken; this.verifier = verifier; }
public void ExchangeForAccessToken_OAuth10() { MockRestServiceServer mockServer = MockRestServiceServer.CreateServer(oauth10.RestTemplate); HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.ContentType = MediaType.APPLICATION_FORM_URLENCODED; mockServer.ExpectNewRequest() .AndExpectUri(ACCESS_TOKEN_URL) .AndExpectMethod(HttpMethod.POST) .AndExpectHeaderContains("Authorization", "oauth_version=\"1.0\"") .AndExpectHeaderContains("Authorization", "oauth_signature_method=\"HMAC-SHA1\"") .AndExpectHeaderContains("Authorization", "oauth_consumer_key=\"consumer_key\"") .AndExpectHeaderContains("Authorization", "oauth_token=\"1234567890\"") .AndExpectHeaderContains("Authorization", "oauth_nonce=\"") .AndExpectHeaderContains("Authorization", "oauth_signature=\"") .AndExpectHeaderContains("Authorization", "oauth_timestamp=\"") .AndRespondWith(EmbeddedResource("AccessToken.formencoded"), responseHeaders); OAuthToken requestToken = new OAuthToken("1234567890", "abcdefghijklmnop"); #if NET_4_0 || SILVERLIGHT_5 OAuthToken accessToken = oauth10.ExchangeForAccessTokenAsync(new AuthorizedRequestToken(requestToken, "verifier"), null).Result; #else OAuthToken accessToken = oauth10.ExchangeForAccessToken(new AuthorizedRequestToken(requestToken, "verifier"), null); #endif Assert.AreEqual("9876543210", accessToken.Value); Assert.AreEqual("ponmlkjihgfedcba", accessToken.Secret); }
private static OAuthToken LoadOAuthToken() { string[] lines = File.ReadAllLines("../../token.txt"); OAuthToken oauthAccessToken = new OAuthToken(lines[0], lines[1]); return oauthAccessToken; }
private static OAuthToken LoadOAuthToken() { //string[] lines = File.ReadAllLines(OAuthTokenFileName); OAuthToken oauthAccessToken = new OAuthToken(first, second); return oauthAccessToken; }
private static OAuthToken LoadOAuthToken() { OAuthToken oauthAccessToken = new OAuthToken("88lixsugnarrd19f", "94ao4bfgaao095k"); return oauthAccessToken; }
private void ContinueLinkApp(AuthenticationToken token) { try { // Get access token either from parameter or from API OAuthToken oauthAccessToken = null; if (token == null) { AuthorizedRequestToken requestToken = new AuthorizedRequestToken(_oauthToken, null); oauthAccessToken = _dropboxServiceProvider.OAuthOperations.ExchangeForAccessTokenAsync(requestToken, null).Result; } else { oauthAccessToken = new OAuthToken(token.Value, token.Secret); } if (OnCloudAuthenticationStatusChanged != null) OnCloudAuthenticationStatusChanged(CloudAuthenticationStatusType.RequestAccessToken); // Get Dropbox API instance _dropbox = _dropboxServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret); //dropbox.Locale = CultureInfo.CurrentUICulture.IetfLanguageTag; // Test Dropbox API connection (get user name from profile) DropboxProfile profile = _dropbox.GetUserProfileAsync().Result; HasLinkedAccount = true; // Save token to hard disk SaveTokenToDisk(new AuthenticationToken() { Value = oauthAccessToken.Value, Secret = oauthAccessToken.Secret, UserName = profile.DisplayName }); if (OnCloudAuthenticationStatusChanged != null) OnCloudAuthenticationStatusChanged(CloudAuthenticationStatusType.ConnectedToDropbox); } catch (AggregateException ae) { HasLinkedAccount = false; ae.Handle(ex => { if (ex is DropboxApiException) { Console.WriteLine(ex.Message); return true; } return false; }); } }
public static OAuthToken LoadOAuthToken() { //string[] lines = File.ReadAllLines(OAuthTokenFileName); OAuthToken oauthAccessToken = new OAuthToken(oAuthToken[0], oAuthToken[1]); return oauthAccessToken; }
public void LinkApp(object view) { try { if (OnCloudAuthenticationStatusChanged != null) OnCloudAuthenticationStatusChanged(CloudAuthenticationStatusType.GetRequestToken); // If the Initialize method has failed the service provider will be null! if(_dropboxServiceProvider == null) _dropboxServiceProvider = new DropboxServiceProvider(DropboxAppKey, DropboxAppSecret, AccessLevel.AppFolder); // Authorization without callback url _oauthToken = _dropboxServiceProvider.OAuthOperations.FetchRequestTokenAsync(null, null).Result; if (OnCloudAuthenticationStatusChanged != null) OnCloudAuthenticationStatusChanged(CloudAuthenticationStatusType.OpenWebBrowser); AuthenticationToken token = null; try { // Try to get a previously saved token token = LoadTokenFromDisk(); } catch { // Ignore exception; use the web browser to get a new token } if (token == null) { // Open web browser for authentication OAuth1Parameters parameters = new OAuth1Parameters(); //parameters.Add("locale", CultureInfo.CurrentUICulture.IetfLanguageTag); // for a localized version of the authorization website string authenticateUrl = _dropboxServiceProvider.OAuthOperations.BuildAuthorizeUrl(_oauthToken.Value, parameters); Process.Start(authenticateUrl); } else { ContinueLinkApp(token); } } catch (AggregateException ae) { HasLinkedAccount = false; ae.Handle(ex => { if (ex is DropboxApiException) { Console.WriteLine(ex.Message); return true; } return false; }); } }
private OAuthToken LoadOAuthToken() { this.oauthAccessToken = new OAuthToken(WebStorageConstants.DropBoxOAuth1, WebStorageConstants.DropBoxOAuth2); return this.oauthAccessToken; }
private OAuthToken LoadOAuthToken() { this.oauthAccessToken = new OAuthToken(DropboxConstants.OAuth1, DropboxConstants.OAuth2); return this.oauthAccessToken; }
private ActionResult SendUpdate(StatusViewModel model, OAuthToken token) { if (!TryValidateModel(model)) { return View("Send", model); } var twitterStatus = new TwitterStatus {Text = model.Status}; //unit of work for db using (IRepository repository = Container.RepositoryFactory()) { twitterStatus = repository.AddStatus(twitterStatus); } //twitter service operation ITwitter twitterClient = TwitterProvider.GetApi(token.Value, token.Secret); twitterClient.TimelineOperations.UpdateStatusAsync(twitterStatus.Text); return RedirectToAction("View", new {id = twitterStatus.Id}); }
public static void SetTwitterAccessToken(this ISessionAdapter obj, OAuthToken value) { obj.SetValue(AccessTokenCode, value); }