Skip to main content

Posts

Showing posts with the label Api

use elasticmail api with golang example

I am not going describe anything about elasticmail itself. You can look at the elasticmails site for details about it. I am writing this post to show you how to use it with your GoLang application. First Create a template in the elastic mail panel. I Don't know why but when I tried to send an email as complete HTML string. It was returning the 404 error. But when using small pieces of HTML tags like just passing <h2> Hello </h2> it was working. So instead of struggling with it, I found another way, Create Custome template on the elasticmails site panel Use the template for mail with passing necessary details[fields] during the API call Create A Template with placeholders Elastic Mail Template Designer Highlighted elements from the left side Templets menu Templet Name / Id Example Placeholders GoLang Code  function to send the email through ElasticMail with the template shown in the image with ...

golang oauth2 facebook example

Todays most sites are integrated with social platforms like twitter, facebook, google plus for one or other purpose. I am writing this post to show how you can integrate Facebook with your golang app using facebook oauth2. Just Some Word About OAuth2 OAuth 2  is an authorization framework that enables applications to obtain limited access to user accounts on an HTTP service, such as Facebook, GitHub, and DigitalOcean. For More information read this article ReadMore Create App For Facebook To integrate Facebook with your golang app, first of all, you have to need a facebook app_id and app_secret. Those are app identifiers for facebook.  To create an app on facebook you should have an account on Facebook ( and ( think you might have already ). Using your Facebook account login on developer.facebook.com   developer facebook portal  After login click on MyApps dropdown and click on Add a New App Button Create a new Facebook app  C...

Getting Started With Google Api client - Golang

google client apis Almost every google api i have integreated with my golang projects have same step. 1. Authroize the user 2. Get the token for user 3. Get the cilent using the token 4. Make furter requset for google api using the client Google api client for golang can be get here here is the example code end of example code Now lets inspect the code what it does. Start from main function where the program starts the exection [line 94] Main function starts [line 96] We are reading the client_id.json file downloaded from the google cloud . It will have information like client_id , project_id, token_id, etc. If you don't have client_id.json create a new one. [line 103] We are reading the json file and adding the permission we want for app on using the ConfigFromJson fucntion.  [line 107] We are getting the http client for the further google api requests using the getClient function. Here This function calls subfunctions [line 24] tokenCach...

golang secure api with jwt

Jwt + Golang For Secured Api For jwt authnetication i am using the  dgrijalva/jwt-go package with my golang project.  First of all fetch packge from repository go get github.com/dgrijalva/jwt-go Now you are ready to use the jwt I am sharing here  my basic code to create secure routes using jwt Here you can see that we have used jwtcheck function as middleware. It processes the request before passing it forward. If request has a valid jwt token than that request get forwarded to the intended function otherwise that request does not forwarded. Hope you find it usefull. If you have any question just ask in comments.