{"_id":"55297f32b316811900149fac","version":{"_id":"550ada9d921b7d0d00228876","forked_from":"550a3b2542fff40d00ae5ffb","project":"550a379f635c660d00527fd8","__v":3,"createdAt":"2015-03-19T14:18:05.245Z","releaseDate":"2015-03-19T14:18:05.245Z","categories":["550ada9d921b7d0d00228877","550ada9d921b7d0d00228878","550ada9d921b7d0d00228879","550ada9d921b7d0d0022887a","550ada9d921b7d0d0022887b","550ada9d921b7d0d0022887c","550ada9d921b7d0d0022887d","5523e61e71c0542100993493","55246f72ccc28a0d0062c560"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"3.0.0","version":"3.0.0"},"__v":4,"project":"550a379f635c660d00527fd8","user":"550a378e635c660d00527fd7","category":{"_id":"550ada9d921b7d0d00228878","version":"550ada9d921b7d0d00228876","__v":4,"pages":["550ada9e921b7d0d0022888c","550ada9e921b7d0d0022888d","550ada9e921b7d0d0022888e","550ada9e921b7d0d0022888f","55121961a575b32f007c79f1","55297f32b316811900149fac","5595b553f4437019002888fc"],"project":"550a379f635c660d00527fd8","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-03-19T02:45:48.278Z","from_sync":false,"order":2,"slug":"authentication","title":"Authentication"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-04-11T20:08:18.109Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":5,"body":"These functions are provided to allow for more flexibility when using Snoocore's OAuth. \n\n## `reddit.getAccessToken()` -> `undefined` or string\n\nGets the current access token for the Snoocore instance if one is set.\n\n## `reddit.setAccessToken(<access_token_string>)`\n\nSets the access token for a Snoocore instance. \n\nNote that it is possible to authenticate by setting the access token directly, e.g.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"reddit.setAccessToken('some_valid_access_token');\\n\\n// This will work if the access token provided is valid!\\n//\\n// No need to call `reddit.auth`\\nreddit('/api/v1/me').get().then(/* */);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n## `reddit.hasAccessToken()` -> boolean\n\nDoes this Snoocore instance have an access token?\n\n## `reddit.getRefreshToken()` -> `undefined` or string\n\nGets the current refresh token for the Snoocore instance if one is set.\n\n## `reddit.setRefreshToken(<refresh_token_string>)`\n\nSets the access token for a Snoocore instance. \n\nNote that it is possible to authenticate by setting the refresh token directly, e.g.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"reddit.setRefreshToken('some_valid_refresh_token');\\n\\n// This will work if the refresh token provided is valid.\\n//\\n// It will handle refreshing the access token -- no need \\n// to call reddit.refresh!\\nreddit('/api/v1/me').get().then(/* */);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n## `reddit.hasRefreshToken()` -> boolean\n\nDoes this Snoocore instance have a refresh token?","excerpt":"","slug":"misc-oauth-functions","type":"basic","title":"Misc. OAuth Functions"}

Misc. OAuth Functions


These functions are provided to allow for more flexibility when using Snoocore's OAuth. ## `reddit.getAccessToken()` -> `undefined` or string Gets the current access token for the Snoocore instance if one is set. ## `reddit.setAccessToken(<access_token_string>)` Sets the access token for a Snoocore instance. Note that it is possible to authenticate by setting the access token directly, e.g. [block:code] { "codes": [ { "code": "reddit.setAccessToken('some_valid_access_token');\n\n// This will work if the access token provided is valid!\n//\n// No need to call `reddit.auth`\nreddit('/api/v1/me').get().then(/* */);", "language": "javascript" } ] } [/block] ## `reddit.hasAccessToken()` -> boolean Does this Snoocore instance have an access token? ## `reddit.getRefreshToken()` -> `undefined` or string Gets the current refresh token for the Snoocore instance if one is set. ## `reddit.setRefreshToken(<refresh_token_string>)` Sets the access token for a Snoocore instance. Note that it is possible to authenticate by setting the refresh token directly, e.g. [block:code] { "codes": [ { "code": "reddit.setRefreshToken('some_valid_refresh_token');\n\n// This will work if the refresh token provided is valid.\n//\n// It will handle refreshing the access token -- no need \n// to call reddit.refresh!\nreddit('/api/v1/me').get().then(/* */);", "language": "javascript" } ] } [/block] ## `reddit.hasRefreshToken()` -> boolean Does this Snoocore instance have a refresh token?