Hi, No, no help whatsoever from them about this. But I did get something working. In essence, you have to manually trigger the Auth ONCE then use a web page to capture the authentication code (once) then use that code in your desktop app where the desktop app uses that code OR the "refresh" token. In fact, you only use the original token once then, from there on, you simply use the last refresh token. (note: the code below was modified by the CC post tool so HTML references may not be quite right) In other words, the work flow is: One time: Write a one-time-use web page to capture the auth code response and store it somewhere, like in a DB. Trigger an AUTH call manually via a web browser. That calls the web page you wrote above and stores the original auth token. Then, and you only have a few seconds to do this before the token expires, run a desktop app that reads the auth token and logins in. This causes the system to send you back a Refresh token. General use: Once you have a refresh token, you're golden because you can login from the desktop with that. Doing so provides a new refresh token for next use. Some code, not all of which is relevant or complete but you'll get the idea. ASPX page to capture the original auth and store it in a DB: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then Doit() End If End Sub Private Sub DoIt() Dim Code As String = "" If Not Request.Params.Item("code") Is Nothing Then Code = Request.Params.Item("code").ToString() end if if code <>"" then OpenConnection() try dim SQL as string sql = "DELETE FROM NameValuePairs WHERE Category ='ConstantContact' AND KeyName = 'AuthorizationCode'" executeSQL(sql) SQL = "INSERT INTO NameValuePairs (Category,KeyName,KeyValue) VALUES ('ConstantContact','AuthorizationCode','" + code + "')" executeSQL(sql) txtEMail.text = code 'debug Catch ex As Exception txtEMail.text = "An error occured while processing your request." finally Con.Close() End Try else txtEMail.text = "no code" end if exit sub End Sub Then … on the desktop side..... Private Const CCBaseURL As String = "https://api.cc.email/v3" Private Const CCAuthenticateURL As String = "https://idfed.constantcontact.com/as/token.oauth2?" Private Function CCAuthorize() As Boolean Dim dn As New Downloader LogIt(gLogFile, "Gettting ConstantContact token...") Dim SQL As String = "SELECT * FROM NameValuePairs WHERE Category='ConstantContact'" Dim DS As DataSet = db.GetDataset(SQL) Dim AuthorizationCode As String = "" Dim r As Boolean = False Dim FileName As String = IO.Path.Combine(Helper.GetSrcXDrive, "SrcX\temp\" + NewGUID() + ".txt") If Database.IsDatasetValid(DS) Then For Each dr As DataRow In DS.Tables(0).Rows Select Case Helper.GetDBString(dr, "KeyName") Case "AuthorizationCode" AuthorizationCode = GetDBString(dr, "KeyValue") Case "RefreshToken" CCRefreshToken = GetDBString(dr, "KeyValue") End Select Next End If If CCRefreshToken <> "" Then 'Great. We'll use that. Dim URL As String = CCAuthenticateURL + "refresh_token=" + CCRefreshToken + "&grant_type=refresh_token" If CCGetAccessToken(URL, FileName) Then LogIt(gLogFile, "Gettting ConstantContact token OK") Return True End If End If 'If RefreshFailed or was not provided... If AuthorizationCode <> "" Then 'In theory, this should only be needed ONCE! Dim URL As String = CCAuthenticateURL + "code=" + AuthorizationCode + "&redirect_uri=" + CCRedirectURL + "&grant_type=authorization_code&scope=contact_data" If CCGetAccessToken(URL, FileName) Then LogIt(gLogFile, "Gettting ConstantContact token OK") Return True End If End If LogIt(gLogFile, "Gettting ConstantContact token FAILED") Return False End Function Private Function CCGetAccessToken(URL As String, FileName As String) As Boolean Dim DN As New Downloader Dim r As Boolean = False Dim SQL As String DN.URL = URL DN.FileName = FileName Dim credentials As String = CCAPIKey + ":" + CCSecret Dim plain As Byte() = System.Text.Encoding.UTF8.GetBytes(credentials) Dim base64cred As String = Convert.ToBase64String(plain) Dim base64auth As String = "Basic " + base64cred DN.Headers.Add("Authorization", base64auth) DN.ContentType = "" r = DN.DownloadFilePOST If r Then Dim dict As Dictionary(Of String, Object) = ReadJSON(FileName) CCAccessToken = dict("access_token").ToString CCRefreshToken = dict("refresh_token").ToString 'cleanup Try IO.File.Delete(DN.FileName) Catch ex As Exception End Try SQL = "DELETE FROM NameValuePairs WHERE Category='ConstantContact' AND KeyName='RefreshToken'" db.ExecuteSQL(SQL) SQL = "INSERT INTO NameValuePairs (Category,KeyName,KeyValue) VALUES ('ConstantContact','RefreshToken','" + CCRefreshToken + "')" db.ExecuteSQL(SQL) End If Return r End Function
... View more