Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsupported authentication token, scheme='none' only allowed when auth is disabled: { scheme='none' } - Neo4j Authentication Error

I am trying to connect to Neo4j from Spark using neo4j-spark-connector. I am facing an authentication issue when I try to connect to the Neo4j org.neo4j.driver.v1.exceptions.AuthenticationException: Unsupported authentication token, scheme='none' only allowed when auth is disabled: { scheme='none' }

I have checked and the credentials I am passing are correct. Not sure why is it failing.

import org.neo4j.spark._
import org.apache.spark._
import org.graphframes._
import org.apache.spark.sql.SparkSession
import org.neo4j.driver.v1.GraphDatabase
import org.neo4j.driver.v1.AuthTokens

val config = new SparkConf()

config.set(Neo4jConfig.prefix + "url", "bolt://localhost")
config.set(Neo4jConfig.prefix + "user", "neo4j")
config.set(Neo4jConfig.prefix + "password", "root")

val sparkSession :SparkSession = SparkSession.builder.config(config).getOrCreate()

val neo = Neo4j(sparkSession.sparkContext)

val graphFrame = neo.pattern(("Person","id"),("KNOWS","null"), ("Employee","id")).partitions(3).rows(1000).loadGraphFrame


println("**********Graphframe Vertices Count************")
graphFrame.vertices.count

println("**********Graphframe Edges Count************")
graphFrame.edges.count


val pageRankFrame = graphFrame.pageRank.maxIter(5).run()
val ranked = pageRankFrame.vertices
ranked.printSchema()

val top3 = ranked.orderBy(ranked.col("pagerank").desc).take(3)

Can someone please have a look and let me know the reason for the same?

like image 626
Mitaksh Gupta Avatar asked Oct 14 '19 13:10

Mitaksh Gupta


2 Answers

It might be a configuration issue with your neo4j.conf file. Is this line commented out:

dbms.security.auth_enabled=false

like image 108
Dave Fauth Avatar answered Nov 02 '22 11:11

Dave Fauth


I had a similar problem, creating the following spring beans fixed the issue.

    @Bean
public org.neo4j.ogm.config.Configuration getConfiguration() {
    return new org.neo4j.ogm.config.Configuration.Builder()
            .credentials("neo4j", "secret")
            .uri("bolt://localhost:7687").build();
}

@Bean
public SessionFactory sessionFactory(org.neo4j.ogm.config.Configuration configuration) {
    return new SessionFactory(configuration,
            "<your base package>");
}
like image 35
lizom Avatar answered Nov 02 '22 10:11

lizom