public Discogs2Finder(IWebUserSettings iwsm) { _Activated = iwsm.DiscogsActivated; _UA = @"Discogs2Net https://sourceforge.net/projects/discog"; _TOut = iwsm.DiscogsTimeOut * 1000; _AuthManager = new DiscogsAuthentificationProvider(iwsm).GetDiscogsOAuthManager(); }
public ActionResult Authenticate() { TwitterBasicProfile twitterBasicProfile = OAuthManager.GetAuthenticatedProfileForTwitter(Request); if (!string.IsNullOrEmpty(twitterBasicProfile.Id)) { return(Content(twitterBasicProfile.Id + "<br/>" + twitterBasicProfile.ScreenName + "<br/>" + twitterBasicProfile.Description)); } return(Content("")); }
public void SetupServices() { if (destinyApi != null && oauthManager != null) { return; } destinyApi = App.provider.GetService(typeof(IDestiny2)) as IDestiny2; oauthManager = App.provider.GetService(typeof(OAuthManager)) as OAuthManager; accountManager = App.provider.GetService(typeof(AccountManager)) as AccountManager; }
// https://www.dropbox.com/developers/core/api#files-GET public bool DownloadFile(string path, Stream downloadStream) { if (!string.IsNullOrEmpty(path) && OAuthInfo.CheckOAuth(AuthInfo)) { string url = Helpers.CombineURL(URLFiles, Helpers.URLPathEncode(path)); string query = OAuthManager.GenerateQuery(url, null, HttpMethod.GET, AuthInfo); return(SendRequest(HttpMethod.GET, downloadStream, query)); } return(false); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary>Initializes a new instance of the <see cref="BV_Connector"/>.Trusted constructor</summary> /// <remarks> 2012/02/16. </remarks> /// <param name="consumerKey">The application Identifier.</param> /// <param name="consumerSecret">The application Secret.</param> /// <param name="certCollection">The certificate collection to attach into the request, /// for SSL client authentication.</param> //////////////////////////////////////////////////////////////////////////////////////////////////// public BV_Connector(string consumerKey, string consumerSecret, X509CertificateCollection certCollection) { if (String.IsNullOrEmpty(consumerKey) || String.IsNullOrEmpty(consumerKey)||(certCollection==null)) { BlueviaException ex = new BlueviaException("Null or Empty parameter when creating a Trusted BV_Connector."); ex.code = ExceptionCode.InvalidArgumentException; throw ex; } oauthManager = new OAuthManager(consumerKey, consumerSecret); base.certCollection = certCollection; }
public TweetStatus TweetMessage(string message) { Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("status", message); string query = OAuthManager.GenerateQuery(URLTweet, args, HttpMethod.Post, AuthInfo); string response = SendPostRequest(query); return(ParseTweetResponse(response)); }
public ActionResult Authenticate() { FacebookProfile facebookProfile = OAuthManager.GetAuthenticatedProfileForFacebook(Request); if (!string.IsNullOrEmpty(facebookProfile.id)) { return(Content(facebookProfile.id + "<br/>" + facebookProfile.first_name + "<br/>" + facebookProfile.last_name)); } return(Content("")); }
public void OAuth_ValidUser() { var oauth = new OAuthManager { GetProvider = s => new OAuthProviderValid(), LoadOrCreateUser = TestUser.Create }; var user = oauth.VerifyUser(TestOAuthProvider.TestProviderName, null); Assert.Equal(TestOAuthProvider.UserName, user.Username); }
public ActionResult LinkedinAuthenticated() { ViewResult result = View("LinkedinError"); LinkedInProfile linkedInProfile = OAuthManager.GetAuthenticatedProfileForLinkedIn(Request); if (linkedInProfile != null) { result = View(linkedInProfile); } return(result); }
public void OAuth_ProviderError() { var oauth = new OAuthManager { GetProvider = s => new OAuthProviderError(), LoadOrCreateUser = TestUser.Create }; // this must return null (we use the OAuthProviderError), even if the LoadOrCreateUser method is defined above var user = oauth.VerifyUser(TestOAuthProvider.TestProviderName, null); Assert.Null(user); }
//http://kbyte.ru/ru/Programming/Articles.aspx?id=82&mode=art Nemiro.OAuth public ActionResult Vk(string provider = "VK") { try { OAuthManager.RegisterClient(new VkontakteClient("", "")); string returnUrl = Url.Action("ExternalLoginResult", "Auth", null, null, Request.Url.Host); return(Redirect(OAuthWeb.GetAuthorizationUrl(provider, returnUrl))); } catch { string returnUrl = Url.Action("ExternalLoginResult", "Auth", null, null, Request.Url.Host); return(Redirect(OAuthWeb.GetAuthorizationUrl(provider, returnUrl))); } }
async void Initialize(object startupObject) { var args = (StartupEventArgs)startupObject; if (!singleInstance.IsFirstInstance) { await singleInstance.SendMessageAsync(args.Args); Environment.Exit(0); } // Finish starting your app (you'll need to use Current.Dispatcher to get back on the UI thread) var services = new ServiceCollection(); var config = new Destiny2.Destiny2Config(APP_NAME, "1.0", "30077", "", ""); config.ApiKey = "c50bb382b1b84e1ba9640125c8f8f299"; config.CustomClientHandlerFunc = () => new HttpClientHandler { CookieContainer = new CookieContainer() }; services.AddDestiny2(config); var oauthManager = new OAuthManager("30077", "oopA-AwO0TL.uN5WEgyTzB0Tv76ewm4PKLEzN1IqmvY", "55593"); services.AddSingleton(oauthManager); var accountManager = new AccountManager(); services.AddSingleton(accountManager); var manifestManager = new ManifestManager(); services.AddSingleton(manifestManager); var inventoryManager = new InventoryManager(); services.AddSingleton(inventoryManager); services.AddSingleton(new InputManager()); services.AddSingleton(new InventorySearcher()); provider = services.BuildServiceProvider(); accountManager.SetupServices(); manifestManager.SetupServices(); inventoryManager.SetupServices(); _ = manifestManager.DownloadManifest(); await OnUiThreadAsync(async() => { await oauthManager.StartAuth(); }); }
public IActionResult GetAccessToken(string code, string state) { if (!string.IsNullOrEmpty(code) && !string.IsNullOrEmpty(state)) { OAuthManager oauthManager = new OAuthManager(_logger); AccessTokenResponse response = oauthManager.GetAccessTokenAsync( new AccessTokenRequest() { ClientId = _configuration.GetValue(ConfigurationKey.CLIENT_ID), ClientSecret = _configuration.GetValue(ConfigurationKey.CLIENT_SECRET), RedirectUri = state, Code = code }) .Result; if (response != null && response.access_token != null) { UsersGetResponse userInfo = oauthManager.GetUserInfoAsync(response.access_token).Result; if (userInfo != null && userInfo.response != null) { _logger.LogWarning(JsonConvert.SerializeObject( new { info = userInfo } )); HttpContext.Response.Cookies.Append("access_token", _jwtManager.GenerateJwtToken(userInfo)); return(Redirect("/")); } _logger.LogError(JsonConvert.SerializeObject( new { error = "Invalid user info" } )); } _logger.LogError(JsonConvert.SerializeObject( new { error = "Can't get access token" } )); } return(Unauthorized()); }
private UploadResult UserUpload(Stream stream, string fileName) { if (AuthInfo == null || string.IsNullOrEmpty(AuthInfo.UserToken) || string.IsNullOrEmpty(AuthInfo.UserSecret)) { Errors.Add("Login is required."); return(null); } string query = OAuthManager.GenerateQuery(URLUserUpload, null, HttpMethod.Post, AuthInfo); UploadResult result = UploadData(stream, query, fileName, "image"); return(ParseResponse(result)); }
protected string GetAuthorizationURL(string requestTokenURL, string authorizeURL, OAuthInfo authInfo, Dictionary <string, string> customParameters = null, HttpMethod httpMethod = HttpMethod.GET) { string url = OAuthManager.GenerateQuery(requestTokenURL, customParameters, httpMethod, authInfo); string response = SendRequest(httpMethod, url); if (!string.IsNullOrEmpty(response)) { return(OAuthManager.GetAuthorizationURL(response, authInfo, authorizeURL)); } return(null); }
void Application_Start(object sender, EventArgs e) { // Code that runs on application startup RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); OAuthManager.RegisterClient ( "google", Hidden.GoogleClientID, Hidden.GoogleSecret ); }
public FlickrPhotosGetSizesResponse PhotosGetSizes(string photoid) { Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("nojsoncallback", "1"); args.Add("format", "json"); args.Add("method", "flickr.photos.getSizes"); args.Add("photo_id", photoid); string query = OAuthManager.GenerateQuery("https://api.flickr.com/services/rest", args, HttpMethod.POST, AuthInfo); string response = SendRequest(HttpMethod.GET, query); return(JsonConvert.DeserializeObject <FlickrPhotosGetSizesResponse>(response)); }
//Registar os vários serviços usados para autenticação public static void initiateAuth() { OAuthManager.RegisterClient( "google", "***********", "***********" ); OAuthManager.RegisterClient( "facebook", "***********", "***********" ); }
/// <summary> /// Creates and returns a shareable link to files or folders. /// Note: Links created by the /shares API call expire after thirty days. /// </summary> /// <returns> /// A shareable link to the file or folder. The link can be used publicly and directs to a preview page of the file. /// Also returns the link's expiration date in Dropbox's usual date format. /// </returns> public DropboxShares CreateShareableLink(string path, string fileName = "") { if (OAuthInfo.CheckOAuth(AuthInfo)) { string url = OAuthManager.GenerateQuery(ZAppHelper.CombineURL(URLShares, path, fileName), null, HttpMethod.Get, AuthInfo); string response = SendGetRequest(url); if (!string.IsNullOrEmpty(response)) { DropboxShares shares = JsonConvert.DeserializeObject <DropboxShares>(response); return(shares); } } return(null); }
public TweetStatus TweetMessage(string message) { Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("status", message); string query = OAuthManager.GenerateQuery(URLTweet, args, HttpMethod.POST, AuthInfo); string response = SendRequest(HttpMethod.POST, query); if (!string.IsNullOrEmpty(response)) { return(JsonConvert.DeserializeObject <TweetStatus>(response)); } return(null); }
public string GetAuthorizationURL() { Dictionary <string, string> args = new Dictionary <string, string>(); args[OAuthManager.ParameterCallback] = "oob"; // Request activation code to validate authentication string url = OAuthManager.GenerateQuery(_jiraRequestToken.ToString(), args, HttpMethod.Post, AuthInfo); string response = SendRequest(HttpMethod.Post, url); if (!string.IsNullOrEmpty(response)) { return(OAuthManager.GetAuthorizationURL(response, AuthInfo, _jiraAuthorize.ToString())); } return(null); }
private void RegisterClient() { OAuthManager.RegisterClient ( new VkontakteClient ( "5042701", "JzLKIvmVK2hrLqd7NeOH" ) { Parameters = new NameValueCollection { { "display", "popup" } }, Scope = "friends, messages" } ); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); // set custom requests provider OAuthManager.SetAuthRequestsProvider(typeof(MemCacheOAuthRequestsProvider)); // OAuth clients registration // NOTE: Specify their own client IDs and secret keys OAuthManager.RegisterClient ( "facebook", "1435890426686808", "c6057dfae399beee9e8dc46a4182e8fd" ); OAuthManager.RegisterClient ( "mail.ru", "722701", "d0622d3d9c9efc69e4ca42aa173b938a" ); OAuthManager.RegisterClient ( "google", "1058655871432-83b9micke7cll89jfmcno5nftha3e95o.apps.googleusercontent.com", "AeEbEGQqoKgOZb41JUVLvEJL" ); OAuthManager.RegisterClient ( "github", "e14122695d88f5c95bce", "cde23ec001c5180e01e865f4efb57cb0bc848c16" ); OAuthManager.RegisterClient ( "live", "0000000040124265", "6ViSGIbw9N59s5Ndsfz-zaeezlBt62Ep" ); }
private void Yandexauthwindow_Loaded(object sender, RoutedEventArgs e) { var client = new YandexClient ( "ef69cea3cf4946d0b00dec064f1b26ee", "9446b005f22f4a5592b5a78d250551d2" ); if (!OAuthManager.IsRegisteredClient("Yandex")) { OAuthManager.RegisterClient ( client ); } yandexweb.Navigate(source: OAuthWeb.GetAuthorizationUrl("Yandex")); }
/// <summary>Retrieves file and folder metadata.</summary> /// <param name="path">The path to the file or folder.</param> /// <returns> /// The metadata for the file or folder at the given <path>. /// If <path> represents a folder and the list parameter is true, the metadata will also include a listing of metadata for the folder's contents. /// </returns> public DropboxDirectoryInfo GetFilesList(string path) { DropboxDirectoryInfo directoryInfo = null; if (OAuthInfo.CheckOAuth(AuthInfo)) { string url = OAuthManager.GenerateQuery(ZAppHelper.CombineURL(URLMetaData, path), null, HttpMethod.Get, AuthInfo); string response = SendGetRequest(url); if (!string.IsNullOrEmpty(response)) { directoryInfo = JsonConvert.DeserializeObject <DropboxDirectoryInfo>(response); } } return(directoryInfo); }
protected NameValueCollection GetAccessTokenEx(string accessTokenURL, OAuthInfo authInfo, HttpMethod httpMethod = HttpMethod.GET) { if (string.IsNullOrEmpty(authInfo.AuthToken) || string.IsNullOrEmpty(authInfo.AuthSecret)) { throw new Exception("Auth infos missing. Open Authorization URL first."); } string url = OAuthManager.GenerateQuery(accessTokenURL, null, httpMethod, authInfo); string response = SendRequest(httpMethod, url); if (!string.IsNullOrEmpty(response)) { return(OAuthManager.ParseAccessTokenResponse(response, authInfo)); } return(null); }
/// <summary> /// Generates an OAuth token for the client (not user). /// </summary> private void GenerateTokenFromClientId() { bool hasValidAuth = false; string authorization = Request.Headers["Authorization"]; if (authorization != null) { if (authorization.StartsWith("basic ")) { string token = authorization.Split(' ')[1]; token = Encoding.ASCII.GetString(Convert.FromBase64String(token)); if (token == FortniteClientId) { hasValidAuth = true; } } } if (hasValidAuth) { var token = OAuthManager.CreateToken((int)ClientAccessTokenExpiry.TotalSeconds); var response = new { access_token = token.Token, expires_in = token.ExpiresIn, expires_at = token.ExpiresAt.ToDateTimeString(), token_type = "bearer", client_id = FortniteClientId.Split(':')[0], internal_client = true, client_service = "fortnite" }; Response.StatusCode = 200; Response.ContentType = "application/json"; Response.Write(JsonConvert.SerializeObject(response)); } else { Response.StatusCode = 403; } }
/// <summary> /// Registartion OAuth clients. /// </summary> private void RegistrationOAuthClients() { foreach (string clientName in ConfigurationManager.AppSettings["oauth:clients"].Split(',')) { if (String.IsNullOrEmpty(ConfigurationManager.AppSettings[String.Format("oauth:{0}:id", clientName)])) { throw new ArgumentNullException(String.Format(Test.Resources.Strings.ClientIdIsRequired, clientName)); } if (String.IsNullOrEmpty(ConfigurationManager.AppSettings[String.Format("oauth:{0}:key", clientName)])) { throw new ArgumentNullException(String.Format(Test.Resources.Strings.ClientKeyIsRequired, clientName)); } // public key for odnoklassniki.ru ArrayList args = null; if (clientName.Equals("odnoklassniki", StringComparison.OrdinalIgnoreCase)) { if (String.IsNullOrEmpty(ConfigurationManager.AppSettings[String.Format("oauth:{0}:publicKey", clientName)])) { throw new ArgumentNullException(String.Format(Test.Resources.Strings.PublicKeyIsRequired, clientName)); } args = new ArrayList(); args.Add(ConfigurationManager.AppSettings[String.Format("oauth:{0}:publicKey", clientName)]); } // -- // necessary permissions string scope = null; if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings[String.Format("oauth:{0}:scope", clientName)])) { scope = ConfigurationManager.AppSettings[String.Format("oauth:{0}:scope", clientName)]; } // -- OAuthManager.RegisterClient ( clientName, ConfigurationManager.AppSettings[String.Format("oauth:{0}:id", clientName)], ConfigurationManager.AppSettings[String.Format("oauth:{0}:key", clientName)], initArgs: (args != null ? args.ToArray() : null), scope: scope ); } }
// https://www.dropbox.com/developers/core/api#files-POST public UploadResult UploadFile(Stream stream, string path, string fileName, bool createShareableURL = false, bool shortURL = true) { if (!OAuthInfo.CheckOAuth(AuthInfo)) { Errors.Add("Login is required."); return(null); } string url = Helpers.CombineURL(URLFiles, Helpers.URLPathEncode(path)); Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("file", fileName); string query = OAuthManager.GenerateQuery(url, args, HttpMethod.Post, AuthInfo); // There's a 150MB limit to all uploads through the API. UploadResult result = UploadData(stream, query, fileName); if (result.IsSuccess) { DropboxContentInfo content = JsonConvert.DeserializeObject <DropboxContentInfo>(result.Response); if (content != null) { if (createShareableURL) { DropboxShares shares = CreateShareableLink(content.Path, shortURL); if (shares != null) { result.URL = shares.URL; } } else { result.URL = GetPublicURL(content.Path); } } } return(result); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary>Initializes a new instance of the <see cref="BV_Connector"/>Untrusted 2 and 3 legged constructor</summary> /// <remarks>2012.05.8 Adding mutual check for token existence. </remarks> /// <param name="consumerKey">The application Identifier.</param> /// <param name="consumerSecret">The application Secret.</param> /// <param name="token">Optional (Mandatory for 3legged behavior): The final customer Identifier.</param> /// <param name="tokenSecret">Optional (Mandatory for 3legged behavior): The final customer Secret.</param> //////////////////////////////////////////////////////////////////////////////////////////////////// public BV_Connector(string consumerKey, string consumerSecret, string token = "", string tokenSecret = "") { if (String.IsNullOrEmpty(consumerKey) || String.IsNullOrEmpty(consumerKey) ) { BlueviaException ex = new BlueviaException("Null or Empty parameter when creating Untrusted BV_Connector."); ex.code = ExceptionCode.InvalidArgumentException; throw ex; } if ((string.IsNullOrWhiteSpace(token) && (!string.IsNullOrWhiteSpace(tokenSecret))) || ((!string.IsNullOrWhiteSpace(token)) && string.IsNullOrWhiteSpace(tokenSecret))) { throw new BlueviaException( "Both token and tokenSecret must be properly filled, or empty, when creating Bluevia Connector." , ExceptionCode.InvalidArgumentException); } oauthManager = new OAuthManager(consumerKey, consumerSecret, token, tokenSecret); }
// https://developers.copy.com/documentation#api-calls/filesystem - Read Root Directory // GET https://api.copy.com/rest/meta/copy public CopyContentInfo GetMetadata(string path) { CopyContentInfo contentInfo = null; if (OAuthInfo.CheckOAuth(AuthInfo)) { string url = URLHelpers.CombineURL(URLMetaData, URLHelpers.URLEncode(path, true)); string query = OAuthManager.GenerateQuery(url, null, HttpMethod.GET, AuthInfo); string response = SendRequest(HttpMethod.GET, query); if (!string.IsNullOrEmpty(response)) { contentInfo = JsonConvert.DeserializeObject <CopyContentInfo>(response); } } return(contentInfo); }
void Application_Start(object sender, EventArgs e) { // Código que se ejecuta al iniciar la aplicación RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); OAuthManager.RegisterClient ( "google", "188020733885-bdb8ombkpbceqp3d1ar23a7f95qa99o8.apps.googleusercontent.com", "NYFcv_bkcgPg_wY1Z104A_i1" ); OAuthManager.RegisterClient ( "facebook", "1978055228883879", "7c47ef27b3c51327b7a0983e03a187c6" ); }
public override UploadResult Upload(Stream stream, string fileName) { if (AuthInfo == null || string.IsNullOrEmpty(AuthInfo.UserToken) || string.IsNullOrEmpty(AuthInfo.UserSecret)) { Errors.Add("Login is required."); return(null); } string url = ZAppHelper.CombineURL(URLFiles, UploadPath); Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("file", fileName); string query = OAuthManager.GenerateQuery(url, args, HttpMethod.Post, AuthInfo); // There's a 150MB limit to all uploads through the API. string response = UploadData(stream, query, fileName); UploadResult result = new UploadResult(response); if (!string.IsNullOrEmpty(response)) { if (AutoCreateShareableLink) { DropboxShares shares = CreateShareableLink(UploadPath, fileName); if (shares != null) { result.URL = shares.URL; } } else { result.URL = GetDropboxURL(AccountInfo.Uid, UploadPath, fileName); } } return(result); }
public DiscogsOAuthBuilder(string iConsumerKey,string iConsumerSecret) { _ConsumerKey=iConsumerKey; _ConsumerSecret=iConsumerSecret; _OAuthManager = new OAuthManager(iConsumerKey, iConsumerSecret); }