mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-07 07:26:05 +12:00
Workaround for Box oauth authorization
This commit is contained in:
parent
80bc60476c
commit
f56ac65fac
|
@ -49,7 +49,6 @@ public static partial class APIKeys
|
||||||
public static string DropboxConsumerSecret = "";
|
public static string DropboxConsumerSecret = "";
|
||||||
public static string MinusConsumerKey = "";
|
public static string MinusConsumerKey = "";
|
||||||
public static string MinusConsumerSecret = "";
|
public static string MinusConsumerSecret = "";
|
||||||
public static string BoxKey = "";
|
|
||||||
public static string BoxClientID = "";
|
public static string BoxClientID = "";
|
||||||
public static string BoxClientSecret = "";
|
public static string BoxClientSecret = "";
|
||||||
public static string SendSpaceKey = "";
|
public static string SendSpaceKey = "";
|
||||||
|
|
127
UploadersLib/GUI/OAuthWebForm.Designer.cs
generated
Normal file
127
UploadersLib/GUI/OAuthWebForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
namespace UploadersLib.GUI
|
||||||
|
{
|
||||||
|
partial class OAuthWebForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.wbMain = new System.Windows.Forms.WebBrowser();
|
||||||
|
this.tscMain = new System.Windows.Forms.ToolStripContainer();
|
||||||
|
this.tsMain = new System.Windows.Forms.ToolStrip();
|
||||||
|
this.tstbURL = new System.Windows.Forms.ToolStripTextBox();
|
||||||
|
this.tslURL = new System.Windows.Forms.ToolStripLabel();
|
||||||
|
this.tscMain.ContentPanel.SuspendLayout();
|
||||||
|
this.tscMain.TopToolStripPanel.SuspendLayout();
|
||||||
|
this.tscMain.SuspendLayout();
|
||||||
|
this.tsMain.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// wbMain
|
||||||
|
//
|
||||||
|
this.wbMain.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.wbMain.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.wbMain.MinimumSize = new System.Drawing.Size(20, 20);
|
||||||
|
this.wbMain.Name = "wbMain";
|
||||||
|
this.wbMain.ScriptErrorsSuppressed = true;
|
||||||
|
this.wbMain.Size = new System.Drawing.Size(1056, 545);
|
||||||
|
this.wbMain.TabIndex = 0;
|
||||||
|
this.wbMain.Navigated += new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.wbMain_Navigated);
|
||||||
|
//
|
||||||
|
// tscMain
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// tscMain.ContentPanel
|
||||||
|
//
|
||||||
|
this.tscMain.ContentPanel.Controls.Add(this.wbMain);
|
||||||
|
this.tscMain.ContentPanel.Size = new System.Drawing.Size(1056, 545);
|
||||||
|
this.tscMain.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tscMain.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.tscMain.Name = "tscMain";
|
||||||
|
this.tscMain.Size = new System.Drawing.Size(1056, 574);
|
||||||
|
this.tscMain.TabIndex = 2;
|
||||||
|
this.tscMain.Text = "toolStripContainer1";
|
||||||
|
//
|
||||||
|
// tscMain.TopToolStripPanel
|
||||||
|
//
|
||||||
|
this.tscMain.TopToolStripPanel.Controls.Add(this.tsMain);
|
||||||
|
//
|
||||||
|
// tsMain
|
||||||
|
//
|
||||||
|
this.tsMain.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
||||||
|
this.tsMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.tslURL,
|
||||||
|
this.tstbURL});
|
||||||
|
this.tsMain.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
|
||||||
|
this.tsMain.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.tsMain.Name = "tsMain";
|
||||||
|
this.tsMain.Padding = new System.Windows.Forms.Padding(3);
|
||||||
|
this.tsMain.Size = new System.Drawing.Size(1056, 29);
|
||||||
|
this.tsMain.Stretch = true;
|
||||||
|
this.tsMain.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// tstbURL
|
||||||
|
//
|
||||||
|
this.tstbURL.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.tstbURL.Name = "tstbURL";
|
||||||
|
this.tstbURL.Size = new System.Drawing.Size(800, 23);
|
||||||
|
//
|
||||||
|
// tslURL
|
||||||
|
//
|
||||||
|
this.tslURL.Name = "tslURL";
|
||||||
|
this.tslURL.Size = new System.Drawing.Size(31, 20);
|
||||||
|
this.tslURL.Text = "URL:";
|
||||||
|
//
|
||||||
|
// OAuthWebForm
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.BackColor = System.Drawing.Color.White;
|
||||||
|
this.ClientSize = new System.Drawing.Size(1056, 574);
|
||||||
|
this.Controls.Add(this.tscMain);
|
||||||
|
this.Name = "OAuthWebForm";
|
||||||
|
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "ShareX - Authorization";
|
||||||
|
this.tscMain.ContentPanel.ResumeLayout(false);
|
||||||
|
this.tscMain.TopToolStripPanel.ResumeLayout(false);
|
||||||
|
this.tscMain.TopToolStripPanel.PerformLayout();
|
||||||
|
this.tscMain.ResumeLayout(false);
|
||||||
|
this.tscMain.PerformLayout();
|
||||||
|
this.tsMain.ResumeLayout(false);
|
||||||
|
this.tsMain.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.WebBrowser wbMain;
|
||||||
|
private System.Windows.Forms.ToolStripContainer tscMain;
|
||||||
|
private System.Windows.Forms.ToolStrip tsMain;
|
||||||
|
private System.Windows.Forms.ToolStripLabel tslURL;
|
||||||
|
private System.Windows.Forms.ToolStripTextBox tstbURL;
|
||||||
|
}
|
||||||
|
}
|
83
UploadersLib/GUI/OAuthWebForm.cs
Normal file
83
UploadersLib/GUI/OAuthWebForm.cs
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
#region License Information (GPL v3)
|
||||||
|
|
||||||
|
/*
|
||||||
|
ShareX - A program that allows you to take screenshots and share any file type
|
||||||
|
Copyright (C) 2008-2014 ShareX Developers
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
|
using HelpersLib;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace UploadersLib.GUI
|
||||||
|
{
|
||||||
|
public partial class OAuthWebForm : Form
|
||||||
|
{
|
||||||
|
public string AuthorizeURL { get; set; }
|
||||||
|
public string CallbackURL { get; set; }
|
||||||
|
public string Code { get; set; }
|
||||||
|
|
||||||
|
public OAuthWebForm(string authorizeURL, string callbackURL)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
Icon = ShareXResources.Icon;
|
||||||
|
AuthorizeURL = authorizeURL;
|
||||||
|
CallbackURL = callbackURL;
|
||||||
|
tstbURL.Text = authorizeURL;
|
||||||
|
wbMain.Navigate(AuthorizeURL);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void wbMain_Navigated(object sender, WebBrowserNavigatedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!IsDisposed)
|
||||||
|
{
|
||||||
|
tstbURL.Text = e.Url.ToString();
|
||||||
|
CheckCallback(e.Url.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckCallback(string url)
|
||||||
|
{
|
||||||
|
if (url.StartsWith(CallbackURL, StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
NameValueCollection args = HttpUtility.ParseQueryString(url);
|
||||||
|
|
||||||
|
if (args != null)
|
||||||
|
{
|
||||||
|
Code = args["code"];
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Code))
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
123
UploadersLib/GUI/OAuthWebForm.resx
Normal file
123
UploadersLib/GUI/OAuthWebForm.resx
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="tsMain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
|
@ -37,6 +37,7 @@
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using UploadersLib.FileUploaders;
|
using UploadersLib.FileUploaders;
|
||||||
using UploadersLib.Forms;
|
using UploadersLib.Forms;
|
||||||
|
using UploadersLib.GUI;
|
||||||
using UploadersLib.HelperClasses;
|
using UploadersLib.HelperClasses;
|
||||||
using UploadersLib.ImageUploaders;
|
using UploadersLib.ImageUploaders;
|
||||||
using UploadersLib.SocialServices;
|
using UploadersLib.SocialServices;
|
||||||
|
@ -643,8 +644,17 @@ public void BoxAuthOpen()
|
||||||
if (!string.IsNullOrEmpty(url))
|
if (!string.IsNullOrEmpty(url))
|
||||||
{
|
{
|
||||||
Config.BoxOAuth2Info = oauth;
|
Config.BoxOAuth2Info = oauth;
|
||||||
Helpers.LoadBrowserAsync(url);
|
//Helpers.LoadBrowserAsync(url);
|
||||||
DebugHelper.WriteLine("BoxAuthOpen - Authorization URL is opened: " + url);
|
DebugHelper.WriteLine("BoxAuthOpen - Authorization URL is opened: " + url);
|
||||||
|
|
||||||
|
// Workaround for authorization because we don't have callback url which starts with https://
|
||||||
|
using (OAuthWebForm oauthForm = new OAuthWebForm(url, "https://www.box.com/home/"))
|
||||||
|
{
|
||||||
|
if (oauthForm.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
BoxAuthComplete(oauthForm.Code);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -167,6 +167,12 @@
|
||||||
<Compile Include="GUI\OAuth2Control.Designer.cs">
|
<Compile Include="GUI\OAuth2Control.Designer.cs">
|
||||||
<DependentUpon>OAuth2Control.cs</DependentUpon>
|
<DependentUpon>OAuth2Control.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="GUI\OAuthWebForm.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="GUI\OAuthWebForm.Designer.cs">
|
||||||
|
<DependentUpon>OAuthWebForm.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="GUI\ResponseForm.cs">
|
<Compile Include="GUI\ResponseForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -323,6 +329,9 @@
|
||||||
<EmbeddedResource Include="GUI\OAuth2Control.resx">
|
<EmbeddedResource Include="GUI\OAuth2Control.resx">
|
||||||
<DependentUpon>OAuth2Control.cs</DependentUpon>
|
<DependentUpon>OAuth2Control.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="GUI\OAuthWebForm.resx">
|
||||||
|
<DependentUpon>OAuthWebForm.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="GUI\ResponseForm.resx">
|
<EmbeddedResource Include="GUI\ResponseForm.resx">
|
||||||
<DependentUpon>ResponseForm.cs</DependentUpon>
|
<DependentUpon>ResponseForm.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
|
Loading…
Reference in a new issue