Trouble understanding how to create a redirect request for a Laravel Api


Hello Everyone,

I am trying to make a redirect request to my backend application’s /oauth/authorize, so I can get a token, and save it… I am having trouble understand how to do this in Angular2, and any suggestions would be much appreciated.

Here is what I have so far in my user.service.ts:

login(user: User) {
    let headers = new Headers();
    headers.append("Content-Type", "application/json");
    headers.append("Access-Control-Allow-Origin", "");
    headers.append("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");

        password: user.password,
        grant_type: "password",
        client_secret: "some-secret",
        client_id: 6,
        code: 1
      { headers: headers }
    .map(response => response.json())
    .do(data => {
      console.log("Data Access Token" + data.Result.access_token);
      Config.token = data.Result.access_token;
  handleErrors(error: Response) {
    console.log("Error Getting Data Access Token");
    return Observable.throw(error);

This is how I think it is supposed to work but from a php perspective:
I need to make an http redirect request from NativeScript like this one here in php:

   $query = http_build_query([
        'client_id' => 6,
        'redirect_uri' => '',
        'response_type' => 'code',
        'scope' => 'conference'
    return redirect('' . $query);

After approving on server the user is forwarded back to the callback where we make a post request to get the access token like below in php:

$http = new GuzzleHttp\Client;
    $response = $http->post('', [
        'form_params' => [
            'grant_type' => 'authorization_code',
            'client_id' => 6, // from admin panel above
            'client_secret' => 'some-secret', 
            'redirect_uri' => '',
            'code' => $request->code // Get code from the callback

$access_token = json_decode((string) $response->getBody(), true)['access_token'];
return $access_token;

Backend Api => Laravel 5.4 with Passport
Nativescript Angular2
tns version 2.5.2