sharepoint online – Authenticate the SmtpClient using AppID and APPSecret instead of passing the username and password

I have the following SharePoint CSOM code inside my c# console application to send an email using the office 365 admin username and password :-

 static private void sendemail(ClientContext context, string subject, string body, FieldUserValue() to, string username, SecureString passWord)

                using (MailMessage mail = new MailMessage())

                    mail.From = new MailAddress("sharepoint@***.com");
                    mail.Subject = subject;
                    mail.IsBodyHtml = true;
                    SmtpClient client = new SmtpClient("***", 25);
                    client.DeliveryMethod = SmtpDeliveryMethod.Network;
                    client.UseDefaultCredentials = false;
                    client.Credentials = new NetworkCredential(username, passWord);
                    client.EnableSsl = true;
                    mail.Body = body;
                    string approvalemailTo = "";

                    foreach (var t in to)
                        approvalemailTo = approvalemailTo + t.Email + ";";

            catch (Exception e)




but to make my code more secure, how i can authenticate the SmtpClient using AppID and APPSecret instead of passing the username and password?


powershell – Could not authenticate to SharePoint Online using OAuth 2.0

I am using following commands to connect to my SharePoint Online environment.

  1. Connect-SPOService -Url “”
  2. Connect-PnPOnline -Url “”

In an ideal case this command should connect me to the site collection. I have verified that I am using correct UserName and Password.

But instead I am getting following errors

For command 1:

Connect-SPOService : Could not authenticate to SharePoint Online using OAuth 2.0 At line:1
+ Connect-SPOService -Url “”
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) (Connect-SPOService), AuthenticationException
+ FullyQualifiedErrorId : Microsoft.Online.SharePoint.PowerShell.AuthenticationException,Microsoft.Online.SharePoint.PowerShell.ConnectSPOService

For command 2:

Connect-PnPOnline : The remote server returned an error: (403)
Forbidden. At line:1 char:1
+ Connect-PnPOnline -Url “ …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) (Connect-PnPOnline), WebException
+ FullyQualifiedErrorId : System.Net.WebException,SharePointPnP.PowerShell.Commands.Base.ConnectOnline

Unusual behavior: When I am running below command.

Connect-PnPOnline -Url 
-PnPO365ManagementShell -LaunchBrowser

i.e. with parameters “PnPO365ManagementShell” “LaunchBrowser“, it works perfectly fine. I am not sure what’s wrong.

Similar behavior
Also I have installed the nuget package for SharePointPnPCoreOnline v3.1.1809 in my Provisioning solution. So when I am running my provisioning code I get same error while establishing connection.

Last thing: When I use same commands from other VMs or colleagues machine with same Creds, it works perfectly fine. Means something is wrong on my machine.

javascript – Cannot POST /authenticate

inserir a descrição da imagem aqui

Gostaria de saber se poderiam me ajudar, to dês de ontem com esse erro já não sei mais o que fazer.


const express = require("express");
const app = express();
const port = 3000;
const connection = require("./database/database");
const userController = require("./user/UserController");
const User = require("./user/User");
const bodyParser = require("body-parser");
const session = require("express-session");
const router  = express.Router()

app.use(bodyParser.urlencoded({ extended: false }));

app.set('view engine', 'ejs');


    secret: "dshjodfiajoiashashjdaas", cookie: {maxAge: 300000}

app.get("/", (req, res) => {


//routes use

app.use("/", userController);

// data base

    .then(() => {
        console.log("Sucess banco de dados");
    .catch((msgErro) => {

app.listen(port, () => {
    console.log("Serve On")


const express = require("express");
const router  = express.Router();
const User = require("./User");
const bcrypt = require('bcryptjs');

router.get("/home", (req, res) =>{

router.get("/error", (req, res) => {

router.get("/erro", (req, res) => {

router.get("/registro", (req, res) => {
});"/registro/users", (req, res) => {
    let email =;
    let senha = req.body.senha;

    User.findOne({where: {email: email}}).then( user => {
        if( user == undefined){
            let salt = bcrypt.genSaltSync(10);
            let hash = bcrypt.hashSync(senha, salt);

                email: email,
                senha: hash
            }).then(() => {
            }).catch((erro) => {
                console.log("Erro da table");
        }else {

   // rota de autenticação de usuario"/authenticate", (req, res) => {
        let email =;
        let senha = req.body.senha;

        User.findOne({where: {email: email}}).then(user => {
            if(user != undefined){ // se existe um usario com esse  email
                //valida  a senha
                let correct = bcrypt.compareSync(senha, user.senha);

                    req.session.user = {




module.exports = router;


<%- include ('partials/header.ejs') %>
    <form action="/authenticate" method="POST">
        <input type="email" name="email">
        <input type="password" name="senha">
        <button type="submit">Logar</button>
        <form action="/registro" method="GET">
            <button type="submit">Registrar</button>
<%- include ('partials/footer.ejs') %>

java – How can I authenticate a PATCH request to Roblox’s group API to update a user’s role?

While making a Discord bot to update a user’s role in both the Discord server and a Roblox group, I kept encountering an authentication issue. I’m using the Discord JDA to make the bot and this URL:{groupId}/users/{userId}?roleId={roleId} to update a user’s role in a group. I’m also using Apache’s httpcomponents library to send a PATCH request to the URL. I’ve tried to use cookies by using the BasicCookieStore from Apache’s httpcomponents, adding the cookie .ROBLOSECURITY with my account’s .ROBLOSECURITY token or code, and setting the BasicCookieStore for the HttpClients as the BasicCookieStore I just mentioned. I’ve also tried setting the header .ROBLOSECURITY in the HttpPatch variable as my account’s .ROBLOSECURITY token or code, but still no luck. In the code below, the commented parts are the cookie method and the rest is the header method I tried. When I ran the code and did the command, the response just says Authorization has been denied for this request. I’ve searched on google for hours now but still no luck. The Roblox dev forums doesn’t really have anything about this too and I can’t post on the Roblox dev forums anyways. Anyone got any ideas on how to authenticate the request?

public class TestRoleCommand extends SimpleCommand {
    public TestRoleCommand() {
        super("testrole", "test role", "testrole");

    public void onCommand(MessageReceivedEvent event, List<String> args) {
        try {
             *BasicCookieStore cookieStore = new BasicCookieStore();
             *BasicClientCookie cookie = new BasicClientCookie(".ROBLOSECURITY", "{token}");
            CloseableHttpClient client = HttpClientBuilder.create().setUserAgent("DiscordBot")./*setDefaultCookieStore(cookieStore).*/build();
            HttpPatch patch = new HttpPatch("");
            patch.setHeader(".ROBLOSECURITY", "{token}");
            HttpResponse response = client.execute(patch);
            StringBuffer buffer = new StringBuffer();
            try (BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))) {
                String line;
                while ((line = reader.readLine()) != null) {
        } catch (Exception e) {

IIS Windows Authentication – Security Prompt wrong address and won’t authenticate

I have 2 servers, one is ours and the other is our client’s (they won’t tell us how they set it up).
I’ve deployed the exact same app on both of them, same apppool settings and windows authentication enabled. This is my result:

  • our server: get Windows Security prompt > enter credentials > logged in
  • client’s server: get Windows Security prompt > enter credentials > unauthorized

The credentials I’ve used on the client’s server is the same credential I’ve used to log into their system and I could also use them to log into their Active Directory via ADExplorer. The domain and credentials seem are correct but it won’t let me login. One thing to note is our server is very simple while the client’s is in an intranet.

I’ve already tried changing various settings in Windows Authentication and Application Pools’ identity.
Does anybody know what setting they may have that would cause this? (we’ve already contacted them but they won’t tell us anything)

domain name system – Anyway to authenticate users for a DNS resolver?

Is there a way to authenticate a user for a DNS resolver, so that I’m the only one capable of using it remotely?

Apparently limiting by IP would be easy but if I were to roam outside and have any IP, that would not be the right solution and I seem to have difficulty finding any other way to limit the access to a DNS resolver and I don’t want it to act as a public resolver.

I can see having VPN to that machine would solve the problem, but is there a simpler way to limit access to a DNS resolver or DNS resolver protocol is meant to run in a trusted LAN only?

json – How to obtain / authenticate user data with a carrier token – Simple OAuth – Decoupled

I am working on a single page application using NUXT and Drupal 8 as headless CMS. for the user authentication token, i use the Simple OAuth Drupal 8 module. Everything works fine. I get the access token when I send a request to this API as you can see below.

enter description of image here

What I want now is to authenticate the user using this token. How will I get the user details every time I refresh the page using this response? Is there an API where we send the bearer access token?

Excuse me please if i use the wrong terms, i am new on decoupled.

But as you know, configure JWT for authentication. we send two requests. 1 request to get the token and another request for the user to use this token as mentioned in this tutorial.

I do not know if I have explained my point correctly. I am totally lost here.

Thank you

php – I cannot authenticate with the api laravel using the sanctum

I am using the laravel sanctum to generate access tokens for my API. I followed step by step the documentation of laravel. I generated a token. But when I access a route that contains middleware auth:sanctum com in the documentation gives a 401 error saying that it is not allowed. Even if I passed the token as a header authorization holder. I followed the step by step correctly but I can't find the problem.

Token generation code

            $user = $this->create($data);
            $token = $user->createToken('acesso',('tipo:'.$user->tipo));
            return $token->plainTextToken;
        }`  Rota no Arquivo api.php `Route::middleware('auth:sanctum')->get("","UserController@users");` Código da requisição com axios `var token = "aeeeabab01978e8edfcba40f523f54b424c2d956e1dfbf856049ad9311241087";
    { headers: { Authorization: `Bearer: ${token}`} })
  .then(response => {
            // If request is good...

linux – Is there a way to configure postgres to authenticate users based on the user under which they are logged in?

I want to run queries against my PostgreSQL databases from scripts and so on, without having to do what I am currently doing:

sudo su - postgres
psql -U USER ...etc

It is cumbersome because I have to type 2 different passwords. Is there a way to configure postgres so that it sees that I'm already logged in as a user that matches the name of a postgres user and log in like that?