Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Reddit authentication
- const remote = require('electron').remote;
- const BrowserWindow = remote.BrowserWindow;
- const snoowrap = require('snoowrap');
- var apiCode;
- const m = new snoowrap({
- userAgent: 'snooredditclient:v1.0.0 (by /u/enejo1)',
- clientId: '{clientid}',
- clientSecret: '',
- refreshToken: '',
- redirectUri: 'http://google.com'
- });
- function myBoi() {
- let myNotification = new Notification('You have recieved a message', {
- body: 'Message content goes here'
- })
- }
- var app = angular.module('snoo-app', ['ngRoute']);
- app.config(function($routeProvider) {
- $routeProvider
- .when('/', {
- templateUrl: './pages/home.html'
- })
- .when('/info', {
- templateUrl: './pages/info.html'
- })
- .when('/test', {
- templateUrl: './pages/testpage.html'
- })
- .when('/account', {
- templateUrl: './pages/account.html'
- })
- .when('/signin', {
- templateUrl: './pages/sign-in.html'
- })
- });
- //All reddit stuff
- function auth() {
- var win = new BrowserWindow({ width: 850, height: 600, frame: false });
- var authURL = snoowrap.getAuthUrl({
- clientId: '{clientid}',
- scope: ['account', 'edit', 'history', 'identity', 'modflair', 'modlog', 'modmail', 'modposts', 'modself', 'modwiki', 'mysubreddits', 'privatemessages', 'read', 'report', 'save', 'submit', 'subscribe', 'vote', 'wikiedit', 'wikiread'],
- redirectUri: 'http://google.com',
- permanent: true,
- state: 'somevalue'
- });
- win.loadURL(authURL);
- win.webContents.on('did-stop-loading', function(event, oldUrl, newUrl, isMainFrame) {
- win.show();
- if (win.webContents.getURL().includes('&code=')) {
- apiCode = win.webContents.getURL().substring(45);
- console.log(apiCode);
- win.close();
- setup();
- }
- });
- }
- function setup() {
- m.fromAuthCode({
- code: apiCode,
- userAgent: 'snooredditclient:v1.0.0 (by /u/enejo1)',
- clientId: '{clientid}',
- redirectUri: 'http://google.com'
- })
- m.getMe().then(console.log);
- return m.getMe().fetch().then(userInfo => {
- console.log(userInfo.name);
- document.getElementById('userAccountName').innerText = userInfo.name;
- document.getElementById('userKarma').innerText = userInfo.link_karma;
- });
- }
- function myDude() {
- return m.getMe().fetch().then(userInfo => {
- console.log(userInfo.name);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement