login about faq

I have looked at the documentation about GMail and I quote:

GMail: If sending via smtp.gmail.com, then send with OAuth2 authentication if possible. Otherwise you will need to change your GMail account settings to allow for sending by less secure apps. See the links below.

I have reviewed the sample code that uses your HTTP library for the task in hand. However, I am already having to fund the Email library and at the moment it is beyond my circumstances to purchase an additional library.

Now, I have already written my own VB.NET utility to communicate with a GMail Calendar and I do the authentication like this:

Private Function DoAuthentication(ByRef rStrToken As String, ByRef rParameters As OAuth2Parameters) As Boolean
    Dim credential As UserCredential
    Dim Secrets = New ClientSecrets() With {
        .ClientId = m_strClientID,
        .ClientSecret = m_strClientSecret
    }
    'm_Scopes.Add(CalendarService.Scope.Calendar)
    m_Scopes.Add("https://www.googleapis.com/auth/calendar https://www.google.com/m8/feeds/")

    Try
        credential = GoogleWebAuthorizationBroker.AuthorizeAsync(Secrets, m_Scopes,
                                                                 "user", CancellationToken.None,
                                                                 New FileDataStore("PublicTalkSoftware.Calendar.Application")).Result()

        ' Create the calendar service using an initializer instance
        Dim initializer As New BaseClientService.Initializer() With {
            .HttpClientInitializer = credential,
            .ApplicationName = "GoogleCalIF"
        }
        m_Service = New CalendarService(initializer)

        rStrToken = credential.Token.AccessToken.ToString()
        rParameters.AccessToken = credential.Token.AccessToken
        rParameters.RefreshToken = credential.Token.RefreshToken
    Catch ex As Exception
        ' We encountered some kind of problem, perhaps they have not yet authenticated?
        ' Can we isolate that as the exception?

        Return False
    End Try

    Return True
End Function

So what I am asking is if they is a similar way that I can do the authentication bit myself so that I can just pass the token needed into the mailman object?

Thanks.

Update

From what I can tell, I can use my same utility that I developed. I jus have to make sure it has requested to use the email API. Then, I follow the same code as above, but using the right scope.

Finally, I should be able to return the token string and just pass that as a parameter to your OAuth2 method.

Tha sound right?

asked Jul 19 at 12:15

Andrew's gravatar image

Andrew
215612

edited Jul 20 at 00:35


I think I have sorted this one out. Things I needed to do:

  1. Update the Google App I had developed to have access to the Gmail API.
  2. Revoke access to my current Google App.
  3. Re-authenticate again so that I was granted the access to the GMail account and make a note of the token.

I use that token with your Email method and it all works. :)

link

answered Jul 20 at 10:09

Andrew's gravatar image

Andrew
215612

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×51
×17

Asked: Jul 19 at 12:15

Seen: 223 times

Last updated: Jul 20 at 10:09

powered by OSQA