{"name":"xoauth2","version":"0.1.1","description":"XOAuth2 token generation for accessing GMail SMTP and IMAP","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/andris9/xoauth2.git"},"keywords":["XOAUTH","XOAUTH2","GMail","SMTP","IMAP"],"author":{"name":"Andris Reinman"},"license":"MIT","dependencies":{"request":"*"},"_id":"xoauth2@0.1.1","dist":{"shasum":"577ae983decf45e98ff4df2c89d0f5fcca1b9416","tarball":"http://registry-npm.ywwl.com/xoauth2/download/xoauth2-0.1.1.tgz","integrity":"sha512-/41xazt8f8XMJMxRdYGxFWbHQP2Z7Fo9omDg3Wu5SsCLFzS4p6vDabI4vuY1XBvsu4oBy4ghqpeekDN72vBDmw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBogkeD7flZSOBcsTs9AxA9+H2ksVs4gKueXpma1lhk4AiEAlRW7DHSwNsq5nqk9E3S/Z0HLhaFb0Wq+1lqqV7u6U8M="}],"size":2634,"noattachment":false,"key":"/xoauth2/-/xoauth2-0.1.1.tgz"},"maintainers":[{"name":"andris","email":"andris@node.ee"}],"directories":{},"readme":"xoauth2\n=======\n\nXOAuth2 token generation with node.js\n\n## Installation\n\n    npm install xoauth2\n\n## Usage\n\n**xoauth2** generates XOAUTH2 login tokens from provided Client and User credentials.\n\nUse `xoauth2.createXOAuth2Generator(options)` to initialize Token Generator\n\nPossible options values:\n\n  * **user** _(Required)_ User e-mail address\n  * **accessUrl** _(Optional)_ Endpoint for token generation (defaults to *https://accounts.google.com/o/oauth2/token*)\n  * **clientId** _(Required)_ Client ID value\n  * **clientSecret** _(Required)_ Client secret value\n  * **refreshToken** _(Required)_ Refresh token for an user\n  * **accessToken** _(Optional)_ initial access token. If not set, a new one will be generated\n  * **timeout** _(Optional)_ TTL in **seconds**\n  * **customHeaders** _(Optional)_ custom headers to send during token generation request [yahoo requires `Authorization: Basic Base64(clientId:clientSecret)` ](https://developer.yahoo.com/oauth2/guide/flows_authcode/#step-5-exchange-refresh-token-for-new-access-token)\n  * **customParams** _(Optional)_ custom payload to send on getToken request [yahoo requires redirect_uri to be specified](https://developer.yahoo.com/oauth2/guide/flows_authcode/#step-5-exchange-refresh-token-for-new-access-token)\n\nSee [https://developers.google.com/identity/protocols/OAuth2WebServer#offline](https://developers.google.com/identity/protocols/OAuth2WebServer#offline) for generating the required credentials\n\nFor Google service account the option values are:\n\n  * **service** _(Required)_ Service account email.\n  * **user** _(Required)_ User e-mail address\n  * **scope** _(Required)_ OAuth2 scope.\n  * **privateKey** _(Required)_ Private key issued for the service account in PEM format, as a string.\n  * **serviceRequestTimeout** _(Optional)_ Expiration value to use in the token request in **seconds**. Maximum is 3600.\n  * **accessUrl** _(Optional)_ Endpoint for token generation (defaults to *https://accounts.google.com/o/oauth2/token*)\n  * **accessToken** _(Optional)_ initial access token. If not set, a new one will be generated\n  * **timeout** _(Optional)_ TTL in **seconds**\n  * **customHeaders** _(Optional)_ custom headers to send during token generation request\n  * **customParams** _(Optional)_ custom payload to send on getToken request\n\n### Methods\n\n#### Request an access token\n\nUse `xoauth2obj.getToken(callback)` to get an access token. If a cached token is found and it should not be expired yet, the cached value will be used.\n\n#### Request for generating a new access token\n\nUse `xoauth2obj.generateToken(callback)` to get an access token. Cache will not be used and a new token is generated.\n\n#### Update access token values\n\nUse `xoauth2obj.updateToken(accessToken, timeout)` to set the new value for the xoauth2 access token. This function emits 'token'\n\n### Events\n\nIf a new token value has been set, `'token'` event is emitted.\n\n    xoauth2obj.on(\"token\", function(token){\n        console.log(\"User: \", token.user); // e-mail address\n        console.log(\"New access token: \", token.accessToken);\n        console.log(\"New access token timeout: \", token.timeout); // TTL in seconds\n    });\n\n### Example\n\n    var xoauth2 = require(\"xoauth2\"),\n        xoauth2gen;\n\n    xoauth2gen = xoauth2.createXOAuth2Generator({\n        user: \"user@gmail.com\",\n        clientId: \"{Client ID}\",\n        clientSecret: \"{Client Secret}\",\n        refreshToken: \"{User Refresh Token}\",\n        customHeaders: {\n          \"HeaderName\": \"HeaderValue\"\n        },\n        customPayload: {\n          \"payloadParamName\": \"payloadValue\"\n        }\n    });\n\n    // ... or for a Google service account\n    xoauth2gen = xoauth2.createXOAuth2Generator({\n        user: \"user@gmail.com\",\n        service: '{Service Email Address}',\n        scope: 'https://mail.google.com/',\n        privateKey: '{Private Key in PEM format}'\n    });\n\n    // SMTP/IMAP\n    xoauth2gen.getToken(function(err, token){\n        if(err){\n            return console.log(err);\n        }\n        console.log(\"AUTH XOAUTH2 \" + token);\n    });\n\n    // HTTP\n    xoauth2gen.getToken(function(err, token, accessToken){\n        if(err){\n            return console.log(err);\n        }\n        console.log(\"Authorization: Bearer \" + accessToken);\n    });\n\n## License\n\n**MIT**\n","publish_time":1347285410924,"_cnpm_publish_time":1347285410924,"dist-tags":{"latest":"1.2.0"}}