How to make thr Repl show the username of the user

Can someone please tell me why this happens?

Hey @clouddrout welcome to the forums!

Thank you for your post and sorry that you are experiencing issues. However, we may not be able to help you with this issue if you do not complete the template fields fully.

Without a code excerpt and/or the link to your Repl there won’t be much we can do to help you.
The more information you provide at the start, the easier it will be to identify the bug in your program.

https://replit.com/@clouddrout/Spah this is his repl. Can’t reproduce the output though

Your Repl does not work.

I suggest you use a GraphQL Template to get user data. That, or use ReplAuth to get user data. The latter verifies the user by making them sign in with Replit. Don’t worry though; it doesn’t steal login information, but rather, takes public information after verifying the user.

If you want to get user info you can either use a Repl Auth template :

  • Node.js
  • Flask

Or Repl identity (go example) :

package main

import (
	"fmt"

	"github.com/replit/go-replidentity"
)

func main() {
    // To prevent security problems, every time we prove our identity
    // to another Repl, it needs to be addressed to it, so that the
    // other Repl cannot grab that identity token and spoof you.
    // In order to do that, we need to get that other Repl's `$REPL_ID`.
    audience := "another-cool-repl-id"

    identityToken, err := replidentity.CreateIdentityTokenAddressedTo(audience)
    if err != nil {
        panic(err)
    }

    // The other Repl can now be sent the identityToken and can verify
    // the authenticity of it!
    // In this case, we'll just immediately verify it for demo purposes.
    
    // audience := os.Getenv("REPL_ID") // uncomment this on the other Repl.
	replIdentity, err := replidentity.VerifyIdentity(
        identityToken,
        audience,
        replidentity.ReadPublicKeyFromEnv,
    )
	if err != nil {
		panic(err)
	}

	fmt.Println()
	fmt.Printf("The identity token (%d bytes) is:\n", len(identityToken))
	fmt.Printf("repl id:     %s\n   user:     %s\n   slug:     %s\n   audience: %s\n  ephemeral: %v\n     origin: %v\n", replIdentity.Replid, replIdentity.User, replIdentity.Slug, replIdentity.Aud, replIdentity.Ephemeral, replIdentity.OriginReplid)
}

In the snipped you get the username and other info!

2 Likes