Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Daniel 19 posts 51 karma points
    Jan 20, 2014 @ 13:24
    Daniel
    0

    Can't authorize service providers

    Hi,

    I just installed this plugin and followed the instructions. I have created a data type for uShare in which I've enabled the Linked in share. When I continue to Content > uShare it says the following:

    "No active service providers. See data type properties to activate."

    What am I doing wrong? When I ran the installation I entered the api and secret code.

    Thanks for your help.

  • Governor Technology 146 posts 551 karma points
    Jan 21, 2014 @ 12:09
    Governor Technology
    0

    Hi Daniel

    This message will show up if uShare cannot find any data types created with the "uShare" Property Editor type and where at least one of them has at least one of the three service providers enabled in the data type properties. To check this, it runs the following script once for each of the three service providers (below is for LinkedIn). If all three scripts returns 0, then the above message will show up.

    SELECT CASE WHEN COUNT (*) > 0 THEN 1 ELSE 0 END FROM cmsDataType dt JOIN cmsDataTypePreValues dtpv ON dt.nodeId = dtpv.datatypeNodeId WHERE LOWER(dt.controlId) = LOWER('B3441080-A1CE-11E2-9688-7F146188709B') AND (LOWER(dtpv.value) like LOWER('%"Show' + 'LinkedIn' + '":true%'))

    Also it might be worth looking at your cmsDataType and cmsDataTypePreValues tables to see if the data is as expected according to this script i.e. if you've enabled LinkedIn in the data type properties, then the cmsDataTypePreValues entry is expected to contain "ShowLinkedIn":true somewhere in its value column.

    Can you please run this script on your database and check the result as well as check your prevalue data to see if it is as expected. Cab you also please confirm your versions of Umbraco and uShare you're using.

    I hope this helps.

    Best regards,

    Rigardt

  • Daniel 19 posts 51 karma points
    Jan 21, 2014 @ 13:25
    Daniel
    0

    Hi again!

    Thank you for your reply. I am using umbraco v 4.8.0 and I downloaded uShare_4.8.1.zip

    When I run the script you pasted it returns '1'. Which seems correct.

    When I look in the cmsDataType table I can see on the last row the guid of the uShare datatype I created.

    When I look in the cmsDataTypePreValues table I see the following under 'value': {"ShowFacebook":false,"ShowLinkedIn":true,"ShowTwitter":false,"SelectFacebookByDefault":false,"SelectLinkedInByDefault":false,"SelectTwitterByDefault":false}

    Which also seems correct.

    Do you have anymore ideas on what I can do? :-)

    Thanks again.

  • Governor Technology 146 posts 551 karma points
    Jan 21, 2014 @ 14:26
    Governor Technology
    0

    Hi Daniel

    Right, I think in that it's perhaps the uShare SqlGateway throwing an exception and returning false instead of true. This is the code for this bit:

    /// <summary>
        /// Returns true if at least one uShare datatype exists with a service provider enabled.
        /// </summary>
        /// <param name="serviceProviderType"></param>
        /// <returns></returns>
        public bool DoesHaveuShareDatatypeWithServiceProviderEnabled(Enums.ServiceProviderType serviceProviderType)
        {
            try
            {
                using (var connection = new SqlConnection(Umbraco.UmbracoGateway.ConnectionString))
                {
                    connection.Open();
    
                    var command = new SqlCommand("uShareDoesHaveDatatypeWithServiceProviderEnabled", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
    
                    command.Parameters.AddWithValue("@ServiceProviderName", serviceProviderType.ToString());
                    command.Parameters.AddWithValue("@uShareDatatypeGuid", Constants.ShareContentDataTypeId);
    
    
                    return command.ExecuteScalar().ToString().Equals("1");
                }
            }
            catch (Exception exception)
            {
                Umbraco.UmbracoGateway.LogError(string.Format("uShare: Error executing SProc uShareDoesHaveDatatypeWithServiceProviderEnabled. Exception: {0}", exception.Message));
    
                return false;
            }
        }
    

    Can you please have a look in the Umbraco log if you can spot the above uShare error and what the reason might be. The default location in 4.8.0 should be in the umbracoLog table I think.

    Regards,

    Rigardt

  • Daniel 19 posts 51 karma points
    Jan 21, 2014 @ 16:03
    Daniel
    0

    Hi again,

    I am not sure if this is what you meant I should look for. But I found this in the umbracoLog table:

    uShare: Error executing SProc uShareDoesHaveDatatypeWithServiceProviderEnabled. Exception: Could not find stored procedure 'uShareDoesHaveDatatypeWithServiceProviderEnabled'.

    I looked in the stores procedures folder in the database but there's no uShare related ones there.

    Cheers, Daniel

  • Governor Technology 146 posts 551 karma points
    Jan 21, 2014 @ 16:43
    Governor Technology
    0

    Hi Daniel

    Yes, this would be causing the issue - a missing stored procedure! It seems that when you installed uShare, it didn't install its stored procedures. Can you please confirm whether you're using SQL Server and which version? Please note that the uShare installation process only supports SQL Server at the moment when adding stored procedures and tables. You can find the entire SQL script that should've been executed on installation in the zip > package.xml file inside the uShare_installExecuteNonQuery > Sqlserver element. If this has run successfully, you should see the following database changes:

    • uShareAuthorizations table
    • uShareServiceProviders table
    • uShareDeleteUserAccessTokens stored procedure
    • uShareDoesHaveDatatypeWithServiceProviderEnabled stored procedure
    • uShareGetUserAccessTokens stored procedure
    • uShareSaveUserAccessTokens stored procedure

    You can perhaps try to run this entire script manually again. You can also look in the same log to see any previous errors that might have occurred during the package installation process.

    Let me know how it goes.

    Regards,

    Rigardt

  • Daniel 19 posts 51 karma points
    Jan 22, 2014 @ 08:21
    Daniel
    0

    Hi again,

    I ran the script manually but got errors:

    Msg 1046, Level 15, State 1, Procedure uShareSaveUserAccessTokens, Line 20 Subqueries are not allowed in this context. Only scalar expressions are allowed.

    I am using an old version of Microsoft SQL Server Management Studio Express v9.00.3042.00. Some things seems to be incompatible and I can't get any further. I think I'm gonna have to let this one go for now and post the links manually.

    Thanks for your kind help.

    Cheers,

    Daniel

  • Governor Technology 146 posts 551 karma points
    Jan 22, 2014 @ 10:59
    Governor Technology
    0

    Hi Daniel For some reason, you cannot run a SELECT sub query inside another. I don't have he same results however did find some resources recommending a specific change to the query. I've amended the entire install script accordingly. Can you please run this and see if it actually does fix the issue. It will drop and recreate any DB items already created so should be safe to run the entire script.

    Edit 1: Actually pasting the script here breaks it due to formatting. Please email me at rigardt AT governor DOT co DOT uk then I'll respond with the new script. 

    Edit 2: I've pasted it again below and this one seems better. If it doesn't work, feel free to email me.

    Regards,

    Rigardt

  • Governor Technology 146 posts 551 karma points
    Jan 22, 2014 @ 11:41
    Governor Technology
    100

    /****** Object:  Table uShareAuthorizations ******/

    IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_uShareAuthorizations_umbracoUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[uShareAuthorizations]'))

    ALTER TABLE [dbo].[uShareAuthorizations] DROP CONSTRAINT [FK_uShareAuthorizations_umbracoUser]

    GO

     

    IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_uShareAuthorizations_uShareServiceProviders]') AND parent_object_id = OBJECT_ID(N'[dbo].[uShareAuthorizations]'))

    ALTER TABLE [dbo].[uShareAuthorizations] DROP CONSTRAINT [FK_uShareAuthorizations_uShareServiceProviders]

    GO

     

    /****** Object:  Table [dbo].[uShareAuthorizations]    Script Date: 04/22/2013 10:15:31 ******/

    IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[uShareAuthorizations]') AND type in (N'U'))

    DROP TABLE [dbo].[uShareAuthorizations]

    GO

     

     

    /****** Object:  Table uShareServiceProviders ******/

    IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[uShareServiceProviders]') AND type in (N'U'))

    DROP TABLE [dbo].[uShareServiceProviders]

    GO

     

     

    /****** Object:  Table [dbo].[uShareServiceProviders]    Script Date: 04/22/2013 10:14:39 ******/

    SET ANSI_NULLS ON

    GO

     

    SET QUOTED_IDENTIFIER ON

    GO

     

    CREATE TABLE [dbo].[uShareServiceProviders](

    [Id] [int] IDENTITY(1,1) NOT NULL,

    [Name] [nvarchar](50) NOT NULL,

     CONSTRAINT [PK_uShareServiceProviders] PRIMARY KEY CLUSTERED 

    (

    [Id] ASC

    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

    ) ON [PRIMARY]

     

    GO

     

     

    /****** Object:  Table [dbo].[uShareAuthorizations]    Script Date: 04/22/2013 10:15:31 ******/

    SET ANSI_NULLS ON

    GO

     

    SET QUOTED_IDENTIFIER ON

    GO

     

    CREATE TABLE [dbo].[uShareAuthorizations](

    [Id] [int] IDENTITY(1,1) NOT NULL,

    [ServiceProviderId] [int] NOT NULL,

    [UmbracoUserId] [int] NOT NULL,

    [AccessTokenValue1] [nvarchar](max) NULL,

    [AccessTokenValue2] [nvarchar](max) NULL,

     CONSTRAINT [PK_uShareAuthorizations] PRIMARY KEY CLUSTERED 

    (

    [Id] ASC

    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

    ) ON [PRIMARY]

     

    GO

     

    ALTER TABLE [dbo].[uShareAuthorizations]  WITH CHECK ADD  CONSTRAINT [FK_uShareAuthorizations_umbracoUser] FOREIGN KEY([UmbracoUserId])

    REFERENCES [dbo].[umbracoUser] ([id])

    GO

     

    ALTER TABLE [dbo].[uShareAuthorizations] CHECK CONSTRAINT [FK_uShareAuthorizations_umbracoUser]

    GO

     

    ALTER TABLE [dbo].[uShareAuthorizations]  WITH CHECK ADD  CONSTRAINT [FK_uShareAuthorizations_uShareServiceProviders] FOREIGN KEY([ServiceProviderId])

    REFERENCES [dbo].[uShareServiceProviders] ([Id])

    GO

     

    ALTER TABLE [dbo].[uShareAuthorizations] CHECK CONSTRAINT [FK_uShareAuthorizations_uShareServiceProviders]

    GO

     

     

    INSERT INTO uShareServiceProviders ([Name]) VALUES ('Facebook')

    GO

     

    INSERT INTO uShareServiceProviders ([Name]) VALUES ('LinkedIn')

    GO

     

    INSERT INTO uShareServiceProviders ([Name]) VALUES ('Twitter')

    GO

     

     

    /****** Object:  StoredProcedure uShareSaveUserAccessToken ******/

    IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[uShareSaveUserAccessTokens]') AND type in (N'P', N'PC'))

    DROP PROCEDURE [dbo].[uShareSaveUserAccessTokens]

    GO

     

    /****** Object:  StoredProcedure uShareSaveUserAccessTokens ******/

    SET ANSI_NULLS ON

    GO

     

    SET QUOTED_IDENTIFIER ON

    GO

     

     

    CREATE PROCEDURE [dbo].[uShareSaveUserAccessTokens] 

    @UmbracoUserId INT,

    @AccessTokenValue1 NVARCHAR(MAX) = NULL,

    @AccessTokenValue2 NVARCHAR(MAX) = NULL,

    @ServiceProviderName NVARCHAR(50)

    AS

    BEGIN

    SET NOCOUNT ON;

     

    BEGIN TRAN

    DECLARE @SP INT

    SET @SP = (SELECT Id FROM uShareServiceProviders WHERE Name = @ServiceProviderName)

     

    UPDATE uShareAuthorizations

    SET AccessTokenValue1 = @AccessTokenValue1, AccessTokenValue2 = @AccessTokenValue2

    WHERE UmbracoUserId = @UmbracoUserId AND ServiceProviderId = @SP

     

    IF @@ROWCOUNT = 0

    BEGIN

    INSERT INTO uShareAuthorizations (ServiceProviderId, UmbracoUserId, AccessTokenValue1, AccessTokenValue2)

    VALUES (@SP, @UmbracoUserId, @AccessTokenValue1, @AccessTokenValue2)

    END

    COMMIT TRAN

    END

     

    GO

     

     

    /****** Object:  StoredProcedure uShareGetUserAccessToken ******/

    IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[uShareGetUserAccessTokens]') AND type in (N'P', N'PC'))

    DROP PROCEDURE [dbo].[uShareGetUserAccessTokens]

    GO

     

    /****** Object:  StoredProcedure uShareGetUserAccessTokens ******/

    SET ANSI_NULLS ON

    GO

     

    SET QUOTED_IDENTIFIER ON

    GO

     

     

    CREATE PROCEDURE [dbo].[uShareGetUserAccessTokens] 

    @UmbracoUserId INT,

    @ServiceProviderName NVARCHAR(50)

    AS

    BEGIN

    SET NOCOUNT ON;

     

    DECLARE @SP INT

    SET @SP = (SELECT Id FROM uShareServiceProviders WHERE Name = @ServiceProviderName)

     

    SELECT AccessTokenValue1, AccessTokenValue2

    FROM uShareAuthorizations

    WHERE UmbracoUserId = @UmbracoUserId AND ServiceProviderId = @SP

    END

     

    GO

     

     

    /****** Object:  StoredProcedure uShareDeleteUserAccessTokens ******/

    IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[uShareDeleteUserAccessTokens]') AND type in (N'P', N'PC'))

    DROP PROCEDURE [dbo].[uShareDeleteUserAccessTokens]

    GO

     

    /****** Object:  StoredProcedure uShareDeleteUserAccessTokens ******/

    SET ANSI_NULLS ON

    GO

     

    SET QUOTED_IDENTIFIER ON

    GO

     

     

    CREATE PROCEDURE [dbo].[uShareDeleteUserAccessTokens] 

    @UmbracoUserId INT,

    @ServiceProviderName NVARCHAR(50)

    AS

    BEGIN

    SET NOCOUNT ON;

     

    DECLARE @SP INT

    SET @SP = (SELECT Id FROM uShareServiceProviders WHERE Name = @ServiceProviderName)

     

    DELETE

    FROM uShareAuthorizations

    WHERE UmbracoUserId = @UmbracoUserId AND ServiceProviderId = @SP

    END

     

    GO

     

     

    /****** Object:  StoredProcedure uShareDoesHaveDatatypeWithServiceProviderEnabled ******/

    IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[uShareDoesHaveDatatypeWithServiceProviderEnabled]') AND type in (N'P', N'PC'))

    DROP PROCEDURE [dbo].[uShareDoesHaveDatatypeWithServiceProviderEnabled]

    GO

     

    /****** Object:  StoredProcedure uShareDoesHaveDatatypeWithServiceProviderEnabled ******/

    SET ANSI_NULLS ON

    GO

     

    SET QUOTED_IDENTIFIER ON

    GO

     

     

    CREATE PROCEDURE [dbo].[uShareDoesHaveDatatypeWithServiceProviderEnabled]

    @ServiceProviderName NVARCHAR(50),

    @uShareDatatypeGuid UNIQUEIDENTIFIER

    AS

    BEGIN

    SET NOCOUNT ON;

     

    SELECT CASE WHEN COUNT (*) > 0 THEN 1 ELSE 0 END

    FROM cmsDataType dt 

    JOIN cmsDataTypePreValues dtpv ON dt.nodeId = dtpv.datatypeNodeId

    WHERE LOWER(dt.controlId) = LOWER(@uShareDatatypeGuid) AND (LOWER(dtpv.value) like LOWER('%"Show' + @ServiceProviderName + '":true%'))

    END

     

    GO    

  • Daniel 19 posts 51 karma points
    Jan 22, 2014 @ 12:33
    Daniel
    0

    That script did actually fix it all. Thank you a bunch!

    I am now gonna go on trying to authorize and post and see how it goes.

    Thanks again for your patience.

    Cheers,

    Daniel

  • Governor Technology 146 posts 551 karma points
    Jan 22, 2014 @ 12:41
    Governor Technology
    0

    Hi Daniel

    Great to hear! Let me know if you have any further questions.

    Rigardt

Please Sign in or register to post replies

Write your reply to:

Draft