Using generic_oauth throws invalid character error


i am using this code for ouath:

i have changed the code in auth to

(new GrafanaOAuth($user))->auth($_GET['state'], $_GET['redirect_uri']);

and GrafanaOauth.php

public function auth(string $state, string $redirect): void { $state = trim(urlencode($state)); $url = $redirect."?state=".$state."&code=cc536d98d27750394a87ab9d057016e636a8ac31";; header("Location: {$url}"); }

Tested it with and the test was ok.

but grafana throws that error in the log msg=login.OAuthLogin(NewTransportWithCode) logger=context userId=0 orgId=0 uname= error="invalid character 'E' looking for beginning of value

can anybody give a hint where to look?