Skip to content

token creation by adding payload consisting of associative array with multiple key value pairs #794

Answered by SvenRtbg
ionics asked this question in Q&A
Discussion options

You must be logged in to vote

Yeah, your "actual token creation" should look like this:

    $builder = $config->builder();

    foreach ($data as $key => $value) {
            $builder->withClaim($key, $value);
    }

Why building the builder inside the loop? If you don't build it because the array is empty, all following code accessing the $builder to get the token will fail because the builder hasn't been created.

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by lcobucci
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #793 on October 05, 2021 09:35.