Showing posts from August, 2016

Api gateway - Api key- 403- "message": "Forbidden"

Aws api gateway with api giving the following error {"message": "Forbidden"} I am working with aws api gateway with nodejs as server. I defined my api using swagger yaml and  deployed to aws api gateway.
Next step is to implement authentication to the api.

Api gateway itself providing authentication mechanism.
Using api key to authenticate the request.

if API keys are enabled, you can set the x-api-key:{api_key} name/value pair here

If the api key is enabled for the api method, then you can set x-api-key: {api_key}  name/value pair in the header.

I used swgger ui and set the api key, but didnt work.
I resolved after few hours struggling.
Change frpm window.swaggerUi.api.clientAuthorizations.add( "bearer", apiKeyAuth ); with window.swaggerUi.api.clientAuthorizations.add( "jsonWebToken", apiKeyAuth );

The name you will assign to the ApiKeyAuthorization from client need to match the name you give the security scheme under swagger definitions.

Oracle database vs MongoDB

Oracle Database:

Oracle uses structured query language for database access.It will store data in tables.
It follows predefined schema and set up rules to govern the relationships.

MongoDB Database:

MongoDB stores data as JSON format. All the related information is stored together for faster data access.
At any time, you can change the structure of records by adding new fields.
It is a database which designed for big data storage and query.
It can gain its performance mainly by key value based design and easy to scale out
To achieve the performance and scalability, MongoDB ditches the transaction support.
We cannot use for transaction related applications like Payment gateway etc.

Both Oracle and MongoDB have a rich query language.
MongoDB is not meant to replace the relational databases.It simply fullfills the different needs.

QR Code Maximum payload/data

 Maximum data qr code can store depends on the following factors.Data type,Number of pixels and error correction level.

 Numeric only - Maximum 7,089 characters (0,1,2...9)

 Alpha Numeric - Maximum 4,296 characters (0–9, A–Z [upper-case only], space, $, %, *, +, -, ., /, :)

 Binary/byte   - Maximum 2,953 characters.

Operators in Swift

Operators:An Operator a special symbol that tells the compiler to perform mathematical or logical operations.
Assignment Operator:
The assignment operator (a=b) initailizes or updates the vlaue of a with a vlue of b.
let b = 12var a = 10a = b  // a is now 12
Arithmetic Operators :

Swift supports 4 arithmetic operators.
Remainder Operator :
9 % 4 = 1
5 % 1.5 = 0.5

Comparison Operator :
Equal to (a == b)Not equal to (a != b)Greater than (a > b)less than (a < b)   .................etc
Ternary Conditional Operator :
Ternary conditional operator is a special operator with 3 parts.
question ? answer 1 : answer 2
if question {answer 1} else {answer2}

if question is true, it evaluates answer 1, otherwise, it evaluates answer 2.
Range Operators:
Closed Range Operator:
The closed range operator (a...b) defines a range from a to b,incluses vlues a and b.
  for index in 1...6 {  print("\(index) times 6 is \(index * 5)")  }  // 1 times 5 is 5  // 2 times 5…

Swift Basics

Swift is an Open Source, powerful language for mac OS, iOS.Swift 3 is the major release developed at

Declaring Constants :
let maximumMembers = 5var minimumMembers = 2let pi = 3.1416
Type Annotations :
var username: Stringusername = "Srinivas Nidadavolu"println(username) // prints Srinivas Nidadavolu
Constant value cannot be changed.
var username = "SRINIVAS NIDADAVOLU"username = "KARUNA" // compile time error - username cannot be changed
Comments :
Comments in swift is similar to other programming languages like java, javascipt and c etc.
// for comment
/* this is also a comment*/
Semicolons:Swift doesnt need a semicolon (;) after every statement. Its optional. If your using multiple statements in the same line, then its required.
Data Types :
32 Bit and 64 bit platforms :
32 bit platform:
Int is Int32UInt is UInt32
64 bit platform:
Int is Int64UInt is UInt64
let userActive = true
if userActive{println("user is active")}else{println("user…