Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple bot #1

Open
Chyper00 opened this issue Aug 30, 2018 · 0 comments
Open

simple bot #1

Chyper00 opened this issue Aug 30, 2018 · 0 comments

Comments

@Chyper00
Copy link

Chyper00 commented Aug 30, 2018

Hello i'm trying to make a simple bot for blogspot with
insert
publish
delete

but i'm stuck on oauth2Client, can you help me ?

What i try :

1° get the token code :

const oauth2Client = new google.auth.OAuth2(
  'CLIENT_ID ,
  'CLIENTE SECRET ID ',
  'REDIRECT URL '
);


const scopes = [
  'https://www.googleapis.com/auth/blogger'
];

const url = oauth2Client.generateAuthUrl({
  // 'online' (default) or 'offline' (gets refresh_token)
  access_type: 'offline',


  scope: scopes
});

console.log(url);

2° paste de url in the browser to login on google

3° then with the tonken code

const {tokens} =  oauth2Client.getToken('TOKEN CODE THAT WAS RETURN )
oauth2Client.setCredentials({
  access_token: tokens, 
  // Optional, provide an expiry_date (milliseconds since the Unix Epoch)
   expiry_date: (new Date()).getTime() + (1000 * 60 * 60 * 24 * 7)
});


const blogger = google.blogger({
  version: 'v3',
  auth: oauth2Client
});

async function runSample () {
  console.log("running")
  const res = blogger.posts.insert({
    blogId: 'BLOGID',
    requestBody: {
      title: 'Hello from the googleapis npm module!',
      content: 'Visit https://github.com/google/google-api-nodejs-client to learn more!'
    }
  });
  console.log(res.data);
  return res.data;
}

runSample();

the response is

Error: No access, refresh token or API key is set

i already refresh the keys and same old thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant