0
votes

We are using VB.NET and developing one Windows Form based application. Where we need to send email using gmail.

Appropriate scope has been approved by Google: scope=https://www.googleapis.com/auth/gmail.send

Using below URL via browser, we are able to retrieve code. https://accounts.google.com/o/oauth2/v2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.send&access_type=offline&include_granted_scopes=true&state=state_parameter_passthrough_value&redirect_uri=**********&response_type=code&client_id=******************

At this point, we have client id, client secret, and code.

But we are unable to send email.

Can someone please share any sample POST request or sample code?

Lanugage used: VB.NET and first URL was called using webbrowser object.

1

1 Answers

0
votes

You are using OAuth2 Authorization Code Grant flow. This flows returns you just a code that you need to exchange for an access token and a refresh token using the /token endpoint. The code is just a random identifier and cannot be used for anything else. Without an access token, you cannot access protected resources (GMail). The /token endpoint requires authentication, so you will need your client ID and secret when calling it.

The workflow, request parameters, responses and examples are covered in the OAuth2 RFC.