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

Facebook sometimes provides back a token longer than 255 characters, which causes an error when inserting into the "token" field. #62

Open
neosign opened this issue Jun 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@neosign
Copy link

neosign commented Jun 25, 2024

Describe the bug
Facebook sometimes provides a token longer than 255 characters, which causes an error when inserting into the "token" field.

To Reproduce
Steps to reproduce the behavior:
1.Navigate to 'Facebook login'.
2.Click 'Login'.
3.A database error occurs for the token field in the [social_provider_user] table.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

System Details

  • OS: Ubuntu
  • Browser chrome
  • Auth Version 1.0.2

Additional context
Consider updating the database schema to assign a specific length to the token field (512 characters should be sufficient).

public function up(): void
    {
        Schema::create('social_provider_user', function (Blueprint $table) {
            $table->foreignId('user_id')->constrained()->onDelete('cascade');
            $table->string('provider_slug'); // maps to providers slug in the devdojo.auth.providers

            $table->string('provider_user_id');
            $table->string('nickname')->nullable();
            $table->string('name')->nullable();
            $table->string('email')->nullable();
            $table->string('avatar')->nullable();
            $table->text('provider_data')->nullable(); // JSON data containing additional provider data we want to include
            
            // Specify lenth in token field default 255 can't handle the real data
            - $table->string('token');
            +$table->string('token', 512);

            $table->string('refresh_token')->nullable();
            $table->timestamp('token_expires_at')->nullable();
            $table->timestamps();

            $table->primary(['user_id', 'provider_slug']);
        });
    }
/**
@neosign neosign added the bug Something isn't working label Jun 25, 2024
@skdishansachin
Copy link
Contributor

@neosign, You have a valid point; sometimes the Facebook token length is longer. There is an interesting discussion about this on Stack Overflow here.

While we can't predict the exact token length, updating the database schema's token field length may not be necessary. Not all providers issue lengthy tokens, and there is no standard token length. The simplest solution would be to change the field length to your preference. What do you think about that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants