Festify / cordova-spotify-oauth

🔐 Easy Spotify authentication for Cordova / PhoneGap apps
MIT License
16 stars 18 forks source link

'auth_failed' error while trying to receive access token #24

Closed Kruszylo closed 4 years ago

Kruszylo commented 4 years ago

Hi, I have been using your plugin in my project without problems until today, when I decided to test authorization after a long time of developing. I was surprised when instead of token I received error 'auth_failed'. After a few hours of evestigating, I decided to reject all possible mistakes and separated authorization into an individual project. And still, when I run the process I see how authorization view pop-ups, then after some time of loading it's hiding down and returns the error. Steps to reproduce the error (on base of this tutorial):

ionic start testspotifyauth blank
cd testspotifyauth
ionic cordova plugin add cordova-spotify-oauth
ionic cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME= testspotifyauth

home.page.ts:

import { Component } from '@angular/core';
import { NavController } from '@ionic/angular';

declare var cordova: any;
@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage {
  result = {};

  constructor(public navCtrl: NavController) { }

  authWithSpotify() {
    const config = {
      clientId: "my spotify id",
      redirectUrl: "whatever://callback",
      scopes: ["streaming", "playlist-read-private", "user-read-email", "user-read-private"],
      tokenExchangeUrl: "https://tmdj-oauth-server.herokuapp.com/exchange",
      tokenRefreshUrl: "https://tmdj-oauth-server.herokuapp.com/refresh",
    };

    cordova.plugins.spotifyAuth.authorize(config)
      .then(({ accessToken, encryptedRefreshToken, expiresAt }) => {
        this.result = { access_token: accessToken, expires_in: expiresAt, ref: encryptedRefreshToken };
        console.log(this.result);
      });
  }
}

home.page.html:

<ion-header>
  <ion-toolbar>
    <ion-title>
      Ionic Blank
    </ion-title>
  </ion-toolbar>
</ion-header>

<ion-content>
  <div class="ion-padding">
    The world is your oyster.
    <ion-button (click)="authWithSpotify()">Auth</ion-button>
  </div>
</ion-content>

I'm not sure where this error comes from, but mb it appeared after I updated my android device. Model: SM-N960F Android version: 9

NeoLegends commented 4 years ago

Hey, can you see any errors in the device console?