AdvTwitter Profile Issue

I'm testing out the TMS Cloud Pack.  My issue is with the AdvTwitter component of that suite.

I created my Twitter app on dev.twitter.com.
I added the proper credentials to the Twitter demo's APPIDS.INC file
I ran the app. 
All is well.  I can retrieve profile info, see friends and followers, etc, exactly as expected.

When I CHANGE to a different Twitter App for different Twitter account the problems begin.

I REPLACE the credentials in the demo's APPIDS.INC file with the new credentials
I run the app.
I do NOT retrieve profile info for the current Twitter account I'm (supposedly) logged in to. I can only see profile info for the Twitter credentials I used the very first time I ran the demo.
When I click the Load Followers button I see followers of the first account as well, not for the current one.  Same is true for the Load Friends button.  It loads friends for the old account, not the current one.

The Twitter App keys I'm using are for two separate Twitter accounts.

So long as I want info for the very first account I set up in APPIDS.INC then it works fine.  It's only when I change the keys in APPIDS.INC that the problems begin and incorrect information is returned. Regardless of credentials used I can only retrieve info for the first account configured in APPIDS.INC. 

I've tried everything I can think of and cannot sort out what is going on or why.  It appears the demo app is saving the very first profile information somewhere, but I cannot find where. 

Any help would be greatly appreciated.

The ONLY thing I'm changing in the Twitter Demo App are the key and secret key entries in the APPIDS.INC file.

Hi,


Please note that the Twitter Demo App is configured to automatically save the access token after authentication (via the SaveTokens call) to avoid having to authenticate each time. As long as the access token remains valid no additional authentication is required.

To remove existing tokens you can use the call: ClearTokens.
To logout the currently logged in Twitter user you can use the call: Logout.

Example:
  AdvTwitter1.ClearTokens;
  AdvTwitter1.Logout; 

That doesn't work either.  BTW I'm using Delphi 10 Berlin with all service packs, just to be clear.

I commented out the SaveTokens call.
I added the Logout call below ClearTokens in the RemoveAccess button event handler.

I ran the program, logged in and logged out so that cleartokens and Logout were called.  I closed the program and ran it again.

Same result.  It's still loading Friends and Followers from the original account used when I first tested the demo.

This is both baffling and frustrating that I cannot get it to respond to the new credentials.

Do you have any other suggestions I could try?

I decided to build a test app from the ground up.

It has the same issue.  It loads the profile information from the first Twitter App I authorized in the TMS Cloud Pack Demo.

How can my new test application be retrieving profile information from the TMS Twitter Demo's first use?

That makes no sense to me but I'm stumped as to what's causing this issue or how to resolve it.

Very
frustrating because I thought the Cloud Pack would be the answer for an
issue I'm facing with a client. 

Unless you're able to help me resolve
this bizarre component behaviour I will have to look elsewhere for a
solution.  NOT my preferred option! I want to use TMS products, not
someone elses.

When you do NOT call LoadTokens at all, there should not be any access token persisted, so it should show a new authentication & authorization screen. On the authentication screen you might have to perform a logout if your browser cached the credentials of a former login.

That is precisely what I've done. 

I do NOT call LoadTokens.  I force the login/authorization screen each time.  I log out and try the second set of credentials.

The result is the same every time. 

Here's the code... maybe you can find fault with it that I'm overlooking.  I'm using a DBIsam database to store Twitter App keys to make switching authentication sets easy. I write out all actions and results to a memo field so I can see what's happening and where.  All very straightforward.  Yet it will not perform as it should.

===================

unit Main;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, AdvSmoothButton, CloudBase,
  CloudBaseWin, CloudCustomTwitter, CloudTwitter, Data.DB, Vcl.StdCtrls,
  Vcl.Grids, Vcl.DBGrids, dbisamtb;

type
  TfrmMain = class(TForm)
    AdvTwitter1: TAdvTwitter;
    btnConnect: TAdvSmoothButton;
    btnLogout: TAdvSmoothButton;
    btnClose: TAdvSmoothButton;
    tblAppKeys: TDBISAMTable;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    tblAppKeysTwitterApplicationName: TStringField;
    MemoTwitterProfile: TMemo;
    tblAppKeysRecNo: TAutoIncField;
    tblAppKeysTwitterOwnerID: TLargeintField;
    tblAppKeysTwitterAccessKey: TStringField;
    tblAppKeysTwitterAccessSecretKey: TStringField;
    tblAppKeysGoogleURLShortenerAPIKey: TStringField;
    procedure btnCloseClick(Sender: TObject);
    procedure btnLogoutClick(Sender: TObject);
    procedure btnConnectClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure AdvTwitter1AccessDenied(Sender: TObject);
    procedure AdvTwitter1AuthFormClose(Sender: TObject);
    procedure AdvTwitter1Connected(Sender: TObject);
    procedure AdvTwitter1ReceivedAccessToken(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure PrintProfileInfo;
  end;

var
  frmMain: TfrmMain;

implementation

{$R *.dfm}

procedure TFrmMain.PrintProfileInfo;
begin
    // Retrieve Twitter Profile Information and Populate Main Screen labels
    MemoTwitterProfile.Lines.Add('');
    MemoTwitterProfile.Lines.Add('Twitter Profile Info');
    MemoTwitterProfile.Lines.Add('');
    MemoTwitterProfile.Lines.Add( 'Screen Name        : ' + AdvTwitter1.Profile.ScreenName );
    MemoTwitterProfile.Lines.Add( 'Twitter ID         : ' + IntToStr(AdvTwitter1.Profile.ID) );
    MemoTwitterProfile.Lines.Add( 'Account Created    : ' + DateTimeToStr(AdvTwitter1.Profile.CreatedAt) );
    MemoTwitterProfile.Lines.Add( 'ListedCount        : ' + IntToStr(AdvTwitter1.Profile.ListedCount) );
    MemoTwitterProfile.Lines.Add( 'Name (Us-Defined)  : ' + AdvTwitter1.Profile.Name );
    MemoTwitterProfile.Lines.Add( 'Favourited Tweets  :' + IntToStr(AdvTwitter1.Profile.StatusCount) );
    MemoTwitterProfile.Lines.Add( 'FollowersCount     : ' + IntToStr(AdvTwitter1.Profile.FollowersCount) );
    MemoTwitterProfile.Lines.Add( 'FriendsCount       : ' + IntToStr(AdvTwitter1.Profile.FriendsCount) );
    if AdvTwitter1.Profile.GeoEnabled then
    begin
       MemoTwitterProfile.Lines.Add( 'GeoTagging Enabled : True' );
    end
    else
    begin
       MemoTwitterProfile.Lines.Add( 'GeoTagging Enabled : False' );
    end;
    MemoTwitterProfile.Lines.Add( 'ImageURL (Avatar)  : ' + AdvTwitter1.Profile.ImageURL );
    MemoTwitterProfile.Lines.Add( 'Status (Last Tweet): ' + AdvTwitter1.Profile.Status.Text );
    MemoTwitterProfile.Lines.Add( 'StatusCount (#)    : ' + IntToStr(AdvTwitter1.Profile.StatusCount) );
    MemoTwitterProfile.Lines.Add( 'TimeZone           : ' + AdvTwitter1.Profile.TimeZone );
    MemoTwitterProfile.Lines.Add( 'URL (User-Provided):' + AdvTwitter1.Profile.URL );
    MemoTwitterProfile.Lines.Add('');
end;


procedure TfrmMain.AdvTwitter1AccessDenied(Sender: TObject);
begin
   //
   MemoTwitterProfile.Lines.Add('');
   MemoTwitterProfile.Lines.Add('======= AdvTGwitterAccessDenied =======');
   MemoTwitterProfile.Lines.Add('');
end;

procedure TfrmMain.AdvTwitter1AuthFormClose(Sender: TObject);
begin
   //
   MemoTwitterProfile.Lines.Add('');
   MemoTwitterProfile.Lines.Add('======= START AdvTwitter1AuthFormClose =======');
   MemoTwitterProfile.Lines.Add('');
   MemoTwitterProfile.Lines.Add('');
   MemoTwitterProfile.Lines.Add('');
   MemoTwitterProfile.Lines.Add('======= END AdvTwitter1AuthFormClose =======');
   MemoTwitterProfile.Lines.Add('');
end;

procedure TfrmMain.AdvTwitter1Connected(Sender: TObject);
begin
   //
   MemoTwitterProfile.Lines.Add('');
   MemoTwitterProfile.Lines.Add('======= START AdvTwitter1Connected =======');
   MemoTwitterProfile.Lines.Add('');
   Caption := 'CONNECTED to ' + tblAppKeys.FieldByName('Twitter Application Name').AsString;
   MemoTwitterProfile.Lines.Add(Caption);
   MemoTwitterProfile.Lines.Add('');
   if AdvTwitter1.GetAccountInfo then
   begin
      MemoTwitterProfile.Lines.Add('AdvTwitter1.GetAccountInfo = TRUE');
   end
   else
   begin
      MemoTwitterProfile.Lines.Add('AdvTwitter1.GetAccountInfo = FALSE');
   end;

   PrintProfileInfo;
   MemoTwitterProfile.Lines.Add('-- 30 --');
   MemoTwitterProfile.Lines.Add('');
   MemoTwitterProfile.Lines.Add('======= END AdvTwitter1Connected =======');
   MemoTwitterProfile.Lines.Add('');
end;

procedure TfrmMain.AdvTwitter1ReceivedAccessToken(Sender: TObject);
begin
   //
   MemoTwitterProfile.Lines.Add('');
   MemoTwitterProfile.Lines.Add('======= START AdvTwitter1ReceivedAccessToken =======');
   MemoTwitterProfile.Lines.Add('');

   MemoTwitterProfile.Lines.Add('');
   MemoTwitterProfile.Lines.Add('======= END AdvTwitter1ReceivedAccessToken =======');
   MemoTwitterProfile.Lines.Add('');
end;

procedure TfrmMain.btnCloseClick(Sender: TObject);
begin
   AdvTwitter1.ClearTokens;
   AdvTwitter1.Logout;
   Close;
end;

procedure TfrmMain.btnConnectClick(Sender: TObject);
begin
   MemoTwitterProfile.Lines.Clear;
   MemoTwitterProfile.Lines.Add('Connecting To ' + tblAppKeys.FieldByName('Twitter Application Name').AsString);
   MemoTwitterProfile.Lines.Add('');
   // Set the Twitter and Google URL Shortener API Keys
   // Twitter API Key
   AdvTwitter1.App.Key     := tblAppKeys.FieldByName('Twitter Access Key').AsString;
   MemoTwitterProfile.Lines.Add('Twitter Access Key : ' + tblAppKeys.FieldByName('Twitter Access Key').AsString);

   // Twitter API Secret Key
   AdvTwitter1.App.Secret  := tblAppKeys.FieldByName('Twitter Access Secret Key').AsString;
   MemoTwitterProfile.Lines.Add('Twitter Access Secret Key : ' + tblAppKeys.FieldByName('Twitter Access Secret Key').AsString);

   // Google Url Shortener API Key
//   AdvURLShortener1.APIKey := tblAppKeys.FieldByName('Google URL Shortener API Key').AsString;
//   MemoTwitterProfile.Lines.Add('Google URL Shortener API Key : ' + tblAppKeys.FieldByName('Google URL Shortener API Key').AsString);
//   MemoTwitterProfile.Lines.Add('');
   MemoTwitterProfile.Lines.Add('');

   MemoTwitterProfile.Lines.Add('');
   MemoTwitterProfile.Lines.Add('AdvTwitter1.Connect;');

   if AdvTwitter1.Connect then
   begin
      MemoTwitterProfile.Lines.Add('AdvTwitter1.Connect = TRUE');
   end
   else
   begin
      MemoTwitterProfile.Lines.Add('AdvTwitter1.Connect = FALSE');
   end;
end;

procedure TfrmMain.btnLogoutClick(Sender: TObject);
begin
   AdvTwitter1.ClearTokens;
   AdvTwitter1.Logout;
end;

procedure TfrmMain.FormCreate(Sender: TObject);
begin
   MemoTwitterProfile.Lines.Clear;
end;

end.

I haven't noticed any issues in the sample code you provided. I also haven't been able to reproduce this issue.

Can you please enable logging for the TAdvTwitter component and provide the automatically generated LOG file so I can further investigate this?

To enable logging set Logging to True and LogLevel to llDetail, the LOG file is generated in your machine's Documents folder by default.