RequestAccess is always returning AuthorizationResult.Pending

SOLVED

I am new to the Sage 50 SDK.  I am trying to write a sample program to connect to a sample company database.  When I call the session "RequestAccess" method, it is always returning "AuthorizationResult.Pending".  Do I need to pass a username and password?  Is it supposed to pop-up a dialog box.

Sample code is shown below.

Const COMPANY_NAME As String = "Bellwether Garden Supply"  
Const APPLICATION_ID As String = "IJ...sew=="  
Dim oSession As New PeachtreeSession()  oSession.Begin(APPLICATION_ID)

Dim oCompanyList As CompanyIdentifierList = oSession.CompanyList  
Dim oCompany As Company  
For Each oCompanyID As CompanyIdentifier In oCompanyList  
   Trace.TraceInformation("Company Name: {0} Path{1}", oCompanyID.CompanyName, oCompanyID.Path)
   If (oCompanyID.CompanyName = COMPANY_NAME) Then     
      Dim oResult As AuthorizationResult = oSession.RequestAccess(oCompanyID)     
       ' -- NOTE: oResult is ALWAYS AuthoriationResult.Pending     
      If (oResult = AuthorizationResult.Granted) Then   
         oCompany = oSession.Open(oCompanyID)      
      End If  
   End If  
Next
oSession.End()

  • 0
    verified answer
    I found the solution to the above problem. After running the above sample code, I opened the test company in the Sage 50 application. After I opened the company, I was presented with a dialog box in the Sage 50 application. The dialog asked me if I want to allow my test application to access the company. I chose the option "Always"

    That resolved the above isse.