GithubHelp home page GithubHelp logo

capacitor-community / apple-sign-in Goto Github PK

View Code? Open in Web Editor NEW
135.0 135.0 58.0 560 KB

Sign in with Apple Support

License: MIT License

Ruby 8.46% Java 15.24% Objective-C 5.89% Swift 35.49% JavaScript 5.41% TypeScript 29.51%

apple-sign-in's People

Contributors

allcontributors[bot] avatar anton-gustafsson avatar dependabot[bot] avatar epicshaggy avatar holmio avatar jcesarmobile avatar jmartinezehp avatar lcsoka avatar mesqueeb avatar mlynch avatar rdlabo avatar renansigolo avatar rlfrahm avatar robingenz avatar seanaye avatar sylvainbigonneau avatar vildhjarta8 avatar vitaliytv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apple-sign-in's Issues

Android and Web Implementation

I see there are pr's open for both of these, but they haven't been merged. I'd like to know if they're going to be merged. I could also work on the implementations if needed.

usage of registerWebPlugin

is it

import { SignInWithApple } from "@capacitor-community/apple-sign-in";
registerWebPlugin(SignInWithApple);

or

import { Plugins } from "@capacitor/core";
registerWebPlugin(Plugins.SignInWithApple);

?

Apple sign-in invalid credential error

step 1:

const response = await SignInWithApple?.authorize({
clientId: 'bundleID',
redirectURI: 'uri',
scopes: 'email name',
state: '12345',
nonce: await this.sha256('nonce')
});

step 2:

{"response":{"identityToken":"jwt_token","authorizationCode":"c1e9cff08403a489899f8d9a553f0eaa7.0.srxv.NLOwAm6zdla_qcaIGKWSSA","email":null,"givenName":null,"user":"000175.eb8a9f72de094925aeb0f8d02d509768.0522","familyName":null}}

step 3:

credential: new OAuthProvider('apple.com')?.credential({
idToken: user?.response?.identityToken,
accessToken: user?.response?.authorizationCode,
rawNonce: 'nonce'
})

step 4:

signInWithCredential(getAuth(), credential)

error: {
"code":"auth/invalid-credential",
"customData":{"appName":"[DEFAULT]"},
"name":"FirebaseError"
}

{"code":"UNIMPLEMENTED"}

Hello,

I have applied your package, however I am getting this error
⚡️ [error] - {"code":"UNIMPLEMENTED"}

my code is

`
let options:SignInWithAppleOptions = {
clientId: 'com.oplusstodio.cortado',
redirectURI: 'https://xxxxxx.firebaseapp.com/__/auth/handler',
scopes: 'email',
state: '12345',
nonce:"nonce"
};

SignInWithApple.authorize(options)
      .then(async (res:SignInWithAppleResponse)=>{
        console.log(res)

        if (res.response && res.response.identityToken) {
        console.log(res)
        console.log(res.response)
    //    this.appAlertService.showAlert(JSON.stringify(res.response))
        }
      })
         .catch((response) => {
    console.log(response)
    //this.presentAlert();
  });

`

I am really confuse, what could be the error... since it dose not tell much

Cant resolve scriptjs

Hi,

I installed the package and imported it (just like the docs). But when I get this error in compilation...

ERROR in ./node_modules/@capacitor-community/apple-sign-in/dist/esm/web.js
Module not found: Error: Can't resolve 'scriptjs' in '/Users/***/node_modules/@capacitor-community/apple-sign-in/dist/esm'
[ERROR] An error occurred while running subprocess ng.

The "state" response field is not returned by plugin

Describe the bug

The state response field should be used to validate the Apple response (it should be the same as the state we send in request options).

Request: see the ASAuthorizationAppleIDRequest and parent ASAuthorizationOpenIDRequest in apple docs:

var state: String?
Data that’s returned to you unmodified in the corresponding credential after a successful authentication.

Response: ASAuthorizationAppleIDCredential docs:

var state: String?
An arbitrary string that your app provides to the request that generates the credential.

To Reproduce

Steps to reproduce the behavior:

  1. Send the authentication request
  2. Dump the response with console.log
  3. Check the logged object
  4. Error: there is no state field in it.

Related code is here and the set of returned fields is:

"user": appleIDCredential.user,
"email": appleIDCredential.email,
"givenName": appleIDCredential.fullName?.givenName,
"familyName": appleIDCredential.fullName?.familyName,
"identityToken": String(data: appleIDCredential.identityToken!, encoding: .utf8),
"authorizationCode": String(data: appleIDCredential.authorizationCode!, encoding: .utf8)

Where appleIDCredential is the ASAuthorizationAppleIDCredential object that has state in it.

Expected behavior

The state is present in the response data.

The solution should be to add:

"state": appleIDCredential.state,

to the response.

Issue with Capacitor 2.5 and apple-sign-in 1.x

I know you started work on Capacitor 3 compatibility, and you put that work on the master branch.

There is however a small issue with the way the package.json was written for this package's version 1.0.0.
image


I can't install it any more on a Capacitor 2.x project...

I made a fix and want to open a PR:

image

However, the version 1.0.0 version of apple-sign-in doesn't have a branch any more, so I can't make the PR towards anything.

Please help!

Sign in with apple on the web not redirecting

Hi folks, I'm not sure if this is a bug, probably more like a settings issue, however I can't proceed with using this plugin on the web. (on a device it works fine). So this is how I start the flow:

SignInWithApple.authorize({
    clientId: environment.appId+'.webapp',
    redirectURI: 'https://api.xxxx.hu/signInWithAppleCallback',
    scopes: 'email name',
    state: '12345',
    //nonce: 'nonce',
  }).then(appleUser => {
    this.sendOauthConnectRequest(OauthProvider.apple, appleUser.response.identityToken).subscribe();
  }).catch(() => {
    this.oauthLoading[oauthProvider] = false;
    return;
  });

clientId is what I registered with apple and the redirect url is OK as well. When I start this call a new window pops up where I am able to log in with my apple ID, but after finishing it, it won't redirect me to the specified URL. As a matter of fact, nothing happens. No errors in the console either. I can see that there is a successful request to "https://appleid.apple.com/appleauth/auth/oauth/authorize", and in the response I can see all the correct authentication data, simply the redirection is not happening. If I close the login window after that, the callback for the error handler is correctly called, thus notifying me, that the login was not successful (which is what is. expected, since the user closed the window). So any idea on why the redirection is not happening? Thanks a lot!

Sign-in hangs on iOS 14

Describe the bug
This only appears to be happening on the simulators. After authorizing my apple credentials the spinner hangs and nothing happens. Apple keeps rejecting my app because of this otherwise I wouldn't be too concerned about it.

Test on simulator. Tried with capacitor 2.2.1 and 2.4.2

SSR breaks the library on Nuxt 3 (`document is not defined`)

Describe the bug
We are trying to use this plugin in an SSR web app built with Nuxt 3 and deployed to Cloudflare Pages.
This library seems to rely on a dependency called ScriptJS which relies on document, which isn't defined when the page is served to the end user.

Here's the line that seems to break the library:

import * as $script from 'scriptjs';

Here's the full log of the error:

[mf:err] ReferenceError: document is not defined
    at definition (/private/Users/user/Documents/project-nuxt3/dist/Users/user/Documents/project-nuxt3/node_modules/scriptjs/dist/script.js:12:13)
    at ZV (/private/Users/user/Documents/project-nuxt3/dist/Users/user/Documents/project-nuxt3/node_modules/scriptjs/dist/script.js:8:72)
    at /private/Users/user/Documents/project-nuxt3/dist/Users/user/Documents/project-nuxt3/node_modules/scriptjs/dist/script.js:11:2
    at SourceTextModule.evaluate (node:internal/vm/module:226:23)
    at VMScriptRunner.runAsModule (/Users/user/Documents/project-nuxt3/node_modules/@miniflare/runner-vm/src/index.ts:40:18)
    at VMScriptRunner.run (/Users/user/Documents/project-nuxt3/node_modules/@miniflare/runner-vm/src/index.ts:86:17)
    at EventTarget.#reload (/Users/user/Documents/project-nuxt3/node_modules/@miniflare/core/src/index.ts:790:13)
    at EventTarget.getPlugins (/Users/user/Documents/project-nuxt3/node_modules/@miniflare/core/src/index.ts:1033:5)
    at createServer (/Users/user/Documents/project-nuxt3/node_modules/@miniflare/http-server/src/index.ts:362:19)
    at startServer (/Users/user/Documents/project-nuxt3/node_modules/@miniflare/http-server/src/index.ts:469:18)

/private/Users/user/Documents/project-nuxt3/dist/Users/user/Documents/project-nuxt3/node_modules/scriptjs/dist/script.js:12
  var doc = document
            ^
ReferenceError: document is not defined
    at definition (/private/Users/user/Documents/project-nuxt3/dist/Users/user/Documents/project-nuxt3/node_modules/scriptjs/dist/script.js:12:13)
    at ZV (/private/Users/user/Documents/project-nuxt3/dist/Users/user/Documents/project-nuxt3/node_modules/scriptjs/dist/script.js:8:72)
    at /private/Users/user/Documents/project-nuxt3/dist/Users/user/Documents/project-nuxt3/node_modules/scriptjs/dist/script.js:11:2
    at SourceTextModule.evaluate (node:internal/vm/module:226:23)
    at VMScriptRunner.runAsModule (/Users/user/Documents/project-nuxt3/node_modules/@miniflare/runner-vm/src/index.ts:40:18)
    at VMScriptRunner.run (/Users/user/Documents/project-nuxt3/node_modules/@miniflare/runner-vm/src/index.ts:86:17)
    at EventTarget.#reload (/Users/user/Documents/project-nuxt3/node_modules/@miniflare/core/src/index.ts:790:13)
    at EventTarget.getPlugins (/Users/user/Documents/project-nuxt3/node_modules/@miniflare/core/src/index.ts:1033:5)
    at createServer (/Users/user/Documents/project-nuxt3/node_modules/@miniflare/http-server/src/index.ts:362:19)
    at startServer (/Users/user/Documents/project-nuxt3/node_modules/@miniflare/http-server/src/index.ts:469:18)
Waiting for the debugger to disconnect...

To Reproduce
Steps to reproduce the behavior:

  1. Create a Nuxt 3 project.
  2. Install the library.
  3. Run the following script to build the project and run a local Wrangler server: "localwrangler": "NITRO_PRESET=cloudflare-pages npx nuxi build && npx wrangler pages dev dist/" (more information here: https://developers.cloudflare.com/workers/wrangler/commands/#dev).
  4. See the error I mentioned on the bug description.

Expected behavior
If the library is used in a web app, it shouldn't have to forcibly rely on document as some apps might not be served as SPAs or rendered on the client-side.

Desktop (please complete the following information):
This doesn't really matter because the web app simply doesn't run, but I'll fill it as the template asks for this information.

  • OS: macOS
  • Browser: Brave
  • Version: Version 1.52.126 Chromium: 114.0.5735.133 (Official Build) (arm64)

Additional context
We made a quick hotfix consisting in a Nuxt plugin forcing this library to be loaded/rendered on the client-side, which always has a defined document.

Here's the code for it:

  1. Create a client-side plugin:
import { SignInWithApple } from '@capacitor-community/apple-sign-in';

export default defineNuxtPlugin(() => {
  return {
    provide: {
      SignInWithApple,
    },
  };
});
  1. Add the plugin inside the component you want to use it in:
const { $SignInWithApple } = useNuxtApp();
  1. Use the plugin inside the sign in method:
const signInApple = async () => {
  try {
    const { response } = await ($SignInWithApple as any).authorize({
      clientId: import.meta.env.VITE_APPLE_CLIENT_ID,
      redirectURI: import.meta.env.VITE_API_URL,
    });

    const data = await loginApi.signInApple({
      token: response.identityToken,
    });
  }
  catch (error) {
    console.log(error);
  }
};

Answer: using apple-sign-in with Firebase-auth

Describe the problem
apple-sign-in plugin v1.0.1 worked great for me with:
"@capacitor/cli": "3.3.2",
"@capacitor/ios": "^3.3.2",
"@capacitor/angular": "^2.0.0",
"@angular/cli": "^13.1.1",
Angular CLI: 13.1.1

BUT when I tried to pass the credentials to Firebase SDK I encountered:
ERROR {"code":"auth/missing-or-invalid-nonce","message":"Nonce is missing in the request."} (as mentioned also in this #60 (comment))

Solution
According to this documentation, when using Firebase's firebase.auth().signInWithCredential, you also required to pass "raw nonce" that, after being hashed, suppose to match the nonce that is contained in the identityToken we get back from this plugin (not sure if this is a new requirement in Firebase's side).

THE CATCH IS that you need to hash the nonce before you pass it in the SignInWithAppleOptions. I used this snippet for hashing nonce:

import {Injectable} from '@angular/core';
import firebase from 'firebase/app';
import { SignInWithApple, SignInWithAppleResponse, SignInWithAppleOptions } from '@capacitor-community/apple-sign-in';


@Injectable({
  providedIn: 'root'
})
export class AuthService {
  
  ...

  async appleLogin() {
    const nonce = 'nonce';
    const hashedNonceHex = await this.sha256(nonce); // see next function
    const options: SignInWithAppleOptions = {
      clientId: 'com.your.app',
      redirectURI: '',
      scopes: 'email, name',
      state: '1256',
      nonce: hashedNonceHex
    };

    SignInWithApple.authorize(options)
      .then(async (res: SignInWithAppleResponse) => {
        if (res.response && res.response.identityToken) {
          const provider = new firebase.auth.OAuthProvider('apple.com');
          const appleCredential = provider.credential({
              idToken: res.response.identityToken,
              rawNonce: nonce,
            });
          firebase.auth().signInWithCredential(appleCredential)
              .then((credential: any) => {
                console.log('credential:' + credential);
              }).catch(err => {
                console.log('signInWithCredential in apple-sign-in caught error');
                console.log(err);
              });
        }
      });
  }


  async sha256(message) {
    // encode as UTF-8
    const msgBuffer = new TextEncoder().encode(message);

    // hash the message
    const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);

    // convert ArrayBuffer to Array
    const hashArray = Array.from(new Uint8Array(hashBuffer));

    // convert bytes to hex string
    const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
    return hashHex;
  }
}

TypeError: undefined is not an object (evaluating 'r.name.firstName')

Describe the bug
I have started getting the given error in my production telemetry when using SignInWithApple.authorize on iOS:

TypeError: undefined is not an object (evaluating 'r.name.firstName')

It seems to be related to this line, which seems to expect name to always be an object, and apparently it doesn't!

Maybe this is due to changes on Apple's side?

To Reproduce

SignInWithApple.authorize({
        clientId: this.appleClientId,
        redirectURI: `${process.env.BASE_URL}/signin`,
        scopes: "email",
        state: "12345",
        nonce: "nonce",
})

Expected behavior
Should probably have a little guard for name to be possibly undefined, such as:

givenName: res.user?.name?.firstName,

Smartphone (please complete the following information):

  • OS: iOS
  • Browser: Mobile Safari
  • Version: v1.0.1

v0.0.12 doesn't work anymore

Describe the bug
v0.0.12 can't work anymore because package.json contains dependency to latest Capacitor which points to latest released Cap3.

To Reproduce
Install v0.0.12 in a fresh new app, ionic serve report compile error.

[ng] Error: node_modules/@capacitor-community/apple-sign-in/node_modules/@capacitor/core/types/definitions-internal.d.ts:16:18 - error TS2430: Interface 'CapacitorInstance' incorrectly extends interface 'CapacitorGlobal'.
[ng]   Types of property 'Plugins' are incompatible.
[ng]     Property 'SignInWithApple' is missing in type '{ [pluginName: string]: { [prop: string]: any; }; }' but required in type 'PluginRegistry'.
[ng] 16 export interface CapacitorInstance extends CapacitorGlobal {
[ng]                     ~~~~~~~~~~~~~~~~~
[ng]   node_modules/@capacitor-community/apple-sign-in/dist/esm/definitions.d.ts:3:9
[ng]     3         SignInWithApple: SignInWithApplePlugin;
[ng]               ~~~~~~~~~~~~~~~
[ng]     'SignInWithApple' is declared here.

Create a new branch to support cap2 is possible. I tried to sent a pull request but it can't work because v0.0.12 is a tag.

Screen Shot 2021-08-06 at 4 01 54 PM

Add usePopup configuration

If someone has also got the problem that the Apple-Sign-In needs to be triggered twice while using an iOs device in the web environment, then it is probably due to a blocked popup. The error popup_blocked_by_browser is being triggered.

It would be nice to be able to set the usePopup option to false:

apple-sign-in/src/web.ts

Lines 36 to 37 in 9828277

nonce: options.nonce ?? undefined,
usePopup: true,

There was already a pull request for this change:
#62

The issue should be reproduceable using the Private Mode in Safari.
Edit: not sure if changing it to non-popup behavior really fixes the issue, should be tested with multiple devices

Issue in android build

I am trying to build android as I am using Apple Signin for ios only
Namespace not specified. Please specify a namespace in the module's build.gradle file like so:

android {
namespace 'com.example.namespace'
}

If the package attribute is specified in the source AndroidManifest.xml, it can be migrated automatically to the namespace value in the build.gradle file using the AGP Upgrade Assistant; please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.

Apple Sign In dialog jumps

Describe the bug

RPReplay_Final1636122200.MP4

My code looks like:

            SignInWithApple.authorize({
                clientId: environment.apple.clientId,
                redirectURI: environment.apple.redirectURI,
                scopes: environment.apple.scope // email name
            })

To Reproduce
Steps to reproduce the behavior:

  1. Open application
  2. Click 'Sign in with Apple' button
  3. Click 'Continue' button

Expected behavior
It should not jumps. I'm moving an app from Cordova IONIC, I don't have this jump behaviour in the same app with IONIC Native plugin.

Smartphone (please complete the following information):

  • Device: iPhone X, XS, Xr
  • OS: iOS
  • Version 15.1

[RESOLVED] [VUE] Error in iOS: "code":"UNIMPLEMENTED" / And in web: SignInWithApple.Authorize() is not implemented on web

Describe the bug
I'm using Capacitor 3 & Quasar Framework (Vue)

To Reproduce

  1. Configure Xcode with Apple Sign In capabilities
  2. Install capacitor plugin (nom install...)
  3. Import to Vue page
    import { SignInWithApple, SignInWithAppleResponse, SignInWithAppleOptions, } from '../../../src-capacitor/node_modules/@capacitor-community/apple-sign-in';
  4. Configure options
const options = {
        clientId: 'domain.name',
        redirectURI: 'https://api.url/login',
        scopes: 'email name',
        state: '12345',
        nonce: 'nonce',
      };
  1. Add function to login
SignInWithApple.Authorize(options)
        .then(async (AppleUser) => {
          if (AppleUser.AppleUserponse && AppleUser.AppleUserponse.identityToken) {
            this.user = AppleUser.AppleUserponse;
            this.$api.post('social_login', AppleUser.AppleUserponse).then(({ data }) => {
              this.$api.defaults.headers = { common: { Authorization: `Bearer ${data.token}` } };
              this.$q.localStorage.set('token', data.token);
              this.$q.localStorage.set('user', data.user);
              this.$store.commit('user', data.user);
              this.$router.push({ name: 'home' });
            }).catch(() => {
              this.$router.push({ name: 'signup', params: AppleUser });
            });
          } else {
            this.presentAlert();
            console.log('Algo ha fallado en el Signin');
          }
        })
        .catch((response) => {
          console.log(response);
          console.log('Algo a fallado en el response');
        });

Then, when I press the button and call the loginApple() I get in Xcode debug :

⚡️  [log] - Entramos en el signin
⚡️  [log] - {"code":"UNIMPLEMENTED"}
⚡️  [log] - Algo a fallado en el response

"Sign Up Not Completed" Error

Describe the bug
When trying to sign in, the modal pops up but produces a "Sign Up Not Completed" Error

To Reproduce
Steps to reproduce the behavior:

  1. Follow installation steps.
  2. Utilize a similar function like below:
/**
 * Creates a user account with Apple
 */
async createAccountWithApple() {
  this.analytics.logEvent('sign_up_apple');
  const options: SignInWithAppleOptions = {
    clientId: '<client-id>',
    redirectURI: '<redirect-uri>',
    scopes: 'email',
    state: '1256',
    nonce: 'nonce'
  };
  return SignInWithApple.authorize(options)
    .then(async (res: SignInWithAppleResponse) => {
      if (res.response && res.response.identityToken) {
        const credential = new firebase.auth.OAuthProvider('apple.com')
          .credential({
            idToken: res.response.identityToken
          });
        return this.auth.signInWithCredential(credential);
      }
    });
}

Expected behavior
The user should be able to sign in.
I have tried also with different redirectURIs and none seem to work
I'm not sure how to utilize a redirectURI for an iOS app. There doesn't seem to be a need as I'm not trying to implement a web platform for this. Is there a way to remove it?

Smartphone (please complete the following information):

  • Device: iPhone 11
  • OS: iOS 14.3
  • Browser: Built in Ionic

Capacitor version error with v1.0.0

Version 1.0.0 has the wrong build target, it is configured for 11.0 but Capacitor 3 requires 12.0, resulting in the following error:

Compiling for iOS 11.0, but module 'Capacitor' has a minimum deployment target of iOS 12.0

Looks like the issue has been resolved in the master, can a new version be deployed to npm.

authorize(options) doesn't work with iOS 14 and 15

Describe the bug
If I try to star the authorization in iOS14-15, nothing happens.
The 'authorize' method promise never resolves.

To Reproduce
Steps to reproduce the behavior:

  1. Implement the authorize()
  2. Click on the "sign in with apple" button
  3. Fill with your credential
  4. See nothing happening

Expected behavior
Get a response with the user informations

Screenshots
Simulator Screen Shot - iPhone 11 - 2021-10-11 at 16 15 05

Smartphone (please complete the following information):

  • Device: iPhone-iPad(simulator and real devices)
  • OS: iOS14-15
  • plugin vers: 0.1.x-1.0.x

[error] - ERROR {} in Xcode console

Describe the bug
I'm new to Capacitor.
In my login.ts I declared a functions named "openAppleSignIn()" using this plugin.
in my login.html I use this function in a button.

"[error] - ERROR {}" in Xcode console when I use "openAppleSignIn()" in Ionic app.

To Reproduce
see Additional context

Screenshots
Schermata 2021-01-17 alle 22 33 32

Desktop (please complete the following information):
iOS 14.3

Smartphone (please complete the following information):
iPhone Xr

Additional context
Here's my login.ts

import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { LoadingController, ToastController, AlertController } from '@ionic/angular';
import { Router } from '@angular/router';
import { AuthService } from '../../services/auth.service';

import { Plugins} from "@capacitor/core";
import {SignInWithApple, SignInWithAppleResponse, SignInWithAppleOptions } from "@capacitor-community/apple-sign-in";

@component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit {

@ViewChild('flipcontainer', { static: false }) flipcontainer: ElementRef;

constructor(private fb: FormBuilder, private authService: AuthService, private loadingCtrl: LoadingController,
private toastCtrl: ToastController, private alertCtrl: AlertController, private router: Router) {}

ngOnInit() {
}

openAppleSignIn() {
Plugins.SignInWithApple.authorize()
.then((result: SignInWithAppleResponse) => {
// Handle user information
// Validate token with server and create new session
console.log(result)
})
.catch((error) => {
// Handle error
console.log(error)
});
}

}

version 1.0 breaking changes?

I see that NPM is on version v1.0
The version here on Github is v0.0.12

I can't find any changelog / breaking changes for v1.0

I'd love to find some information on this!

Dependencies Problem "@capacitor/core": "latest", "@capacitor/ios": "latest" and "@capacitor/android": "latest" breaks builds : New Capacitor 3.x Release

Describe the bug
The dependencies "@capacitor/core": "latest", "@capacitor/ios" and "@capacitor/android" are specified to the latest version.

The new Capacitor 3.0 was released yesterday and now the builds of Capacitor 2.X apps, are broken, because internally this plugin installs the new Capacitor 3.0 (latest version).

Older Capacitor 2.x apps seems to be broken because of this dependency, and new Capacitor 3.X apps still have the same problem because this plugin does not support yet Capacitor 3.X.

To Reproduce
Steps to reproduce the behavior:

  1. Use an "old" Capacitor 2.X project;
  2. Add this plugin to the project;
  3. Try to run the project.

Reported Error
Error: node_modules/@capacitor-community/apple-sign-in/node_modules/@capacitor/core/types/definitions-internal.d.ts:16:18 - error TS2430: Interface 'CapacitorInstance' incorrectly extends interface 'CapacitorGlobal'. [ng] Types of property 'Plugins' are incompatible. [ng] Property 'SignInWithApple' is missing in type '{ [pluginName: string]: { [prop: string]: any; }; }' but required in type 'PluginRegistry'. [ng] 16 export interface CapacitorInstance extends CapacitorGlobal { [ng] ~~~~~~~~~~~~~~~~~ [ng] node_modules/@capacitor-community/apple-sign-in/dist/esm/definitions.d.ts:3:9 [ng] 3 SignInWithApple: SignInWithApplePlugin; [ng] ~~~~~~~~~~~~~~~ [ng] 'SignInWithApple' is declared here.

Expected behavior
The Capacitor dependencies should be specified to a specific version so older versions of capacitor could still use this plugin and build the app.

A new release should be created with a "pinned" version the latest Capacitor 2.X.X version so the support to older apps could still be possible.

And eventually a new version should be release to add support to the new Capacitor 3.X.X.

Screenshots
image

Obtain client_secret in order to revoke the token

I've received the following email from Apple yesterday:

_Starting June 30, 2022, apps submitted to the App Store that support account creation must also include an option to initiate account deletion.

We noticed this app may support account creation. If it does not, you may disregard this message. If it already offers account deletion or you’re working to implement it, we appreciate your efforts to follow the App Store Review Guidelines. Apps submitted after June 30 that do not comply with the account deletion requirements in guideline 5.1.1(v) will not pass review.

Learn more about the account deletion requirements. If your app offers Sign in with Apple, use the Sign in with Apple REST API to revoke user tokens._

Following the instructions on https://developer.apple.com/documentation/sign_in_with_apple/revoke_tokens, it mentions a "client_secret" used in the login flow. I've searched through the code and in other issues, but can't seem to found any relevant information.

Any idea on how to get that value?

Found this SO topic that follows the same subject, but it haven't any concrete answer yet: https://stackoverflow.com/questions/72399534/how-to-make-apple-sign-in-revoke-token-post-request

Can't find module @capacitor-community/apple-sign-in with Capacitor 3

Describe the bug
I'm upgrading and app from Capacitor 2.0 to Capacitor 3.0.

The last plugin that needs to be migrated is this one.

I tried to update to the latest version with no luck.

How can I install the latest version compatible with Capacitor 3?

In the repo there's a 1.0.0 release, but the latest npm release is version 0.1.2.
I also tried to install directly from GitHub, npm install capacitor-community/apple-sign-in but I always get an error:

./src/app/services/authentication.service.ts:11:0-69 - Error: Module not found: Error: Can't resolve '@capacitor-community/apple-sign-in' in 'D:_git\MyApp\MyApp\src\app\services'
[ng] Error: src/app/services/authentication.service.ts:12:82 - error TS2307: Cannot find module '@capacitor-community/apple-sign-in' or its corresponding type declarations.
[ng] 12 import { SignInWithApple, SignInWithAppleResponse, SignInWithAppleOptions } from '@capacitor-community/apple-sign-in';

Screenshots
image

How can I successfully install and use this plugin with Capacitor 3.0?

How do you implement Sign in With Apple in Ios

FOR: "@capacitor-community/apple-sign-in": "^0.2.0",

How do you implement OPTIONS in native IoS?

      const options = {
        clientId: '<<appId>>',
        scopes: 'email name',
        redirectURI: '<<appId>>',
        state: '12345',
        nonce: 'nonce',
      }

currently this is my current implementation on what I saw on the other issues raised, however, it was not working. can someone please help me in setting up this options? thank you

Library not loaded: '@rpath/CapacitorCommunityAppleSignIn.framework/CapacitorCommunityAppleSignIn'

Capacitor Version
Latest Dependencies:

@capacitor/cli: 5.0.5
@capacitor/core: 5.0.5
@capacitor/android: 5.0.5
@capacitor/ios: 5.0.5

Installed Dependencies:

@capacitor/cli: 5.0.4
@capacitor/core: 5.0.4
@capacitor/android: 5.0.4
@capacitor/ios: 5.0.4

[info] Using Gemfile: RubyGems bundle installed
[success] iOS looking great! 👌
Affected Platform(s)
IOS

Current behavior
After running Npx cap open ios, when xcode builds and runs the app it breaks on startup on the physical iphone. The splash screen loads and instantly disappears.

Expected behavior
Expected to launch normally with login screen or main screen.

To Reproduce
Steps to reproduce the behavior:

  1. ng build
  2. npx cap copy
  3. npx cap sync
  4. npx cap open ios
  5. build and run on iphone in xcode

Other Technical Details
npm --version output: 7.15.1

node --version output: v16.15.1

pod --version output (iOS issues only): 1.11.3

I use paid Apple Developer Program to sign on Xcode.

No Exported Member

Describe the bug
There is a compilation error after the installation of the plugin using Ionic 5 with Angular.
``
error TS2305: Module '"../../../node_modules/@capacitor-community/apple-sign-in/dist/esm"' has no exported member 'ResponseSignInWithApplePlugin'.
14 import { ResponseSignInWithApplePlugin } from '@capacitor-community/apple-sign-in';


**To Reproduce**
Steps to reproduce the behavior:
Added the plugin exactly like description.

**Expected behavior**
To compile with no errors.

**Smartphone (please complete the following information):**
 - Device: iPhone X
 - OS: iOS 13.5.1
 - Ionic 5

Cant get email and name scopes

Describe the bug
SignInWithApple.authorize({
clientId: [clientId],
redirectURI: [redirectURI],
scopes: 'email name',
state: '12345',
nonce: 'nonce',
})

Not returning email and name

To Reproduce
Steps to reproduce the behavior:
1.
SignInWithApple.authorize({
clientId: [clientId],
redirectURI: [redirectURI],
scopes: 'email name',
state: '12345',
nonce: 'nonce',
}).then(response => console.log(response))

Expected behavior
return response w name and email
{
response: {
authorizationCode: [authorizationCode],
email: [email]
familyName: [familyName]
givenName: [givenName],
identityToken: [identityToken],
user: [appleUserId]
}
}

Screenshots
Screen Shot 2022-05-28 at 12 49 23

Smartphone (please complete the following information):

  • Device: iPhone 6s
  • OS: 15.5

Capacitor 3 Support

@mlynch According to this issue, rlfrahm/capacitor-apple-login#3, you forked this repo to maintain it and provide support because it's necessary. However, right now there is no way that I can get this working with Capacitor 3.

This paired with the fact that capacitor-community/facebook-login is no longer supporting capacitor version 2, capacitor-community/facebook-login#63, makes it impossible for us to move forward with any kind of updates that facebook is requiring and will thus leave our authentication for any kind of app that supports third-party auth in disarray when it comes to using the capacitor framework since Apple requires you implement Apple Sign In if you implement any other third-party Auth.

It looks like the updates were made in the master branch to support Cap version 3? Is this not the case? We desperately need this to support Capacitor Version 3.

I have version 1.0.0 installed, yet when I try to do an iOS Build I'm getting the following error.

ERROR in node_modules/@capacitor/core/types/definitions-internal.d.ts:16:18 - error TS2430: Interface 'CapacitorInstance' incorrectly extends interface 'CapacitorGlobal'.
  Types of property 'Plugins' are incompatible.
    Property 'SignInWithApple' is missing in type '{ [pluginName: string]: { [prop: string]: any; }; }' but required in type 'PluginRegistry'.

16 export interface CapacitorInstance extends CapacitorGlobal {
                    ~~~~~~~~~~~~~~~~~

  node_modules/@capacitor-community/apple-sign-in/dist/esm/definitions.d.ts:3:9
    3         SignInWithApple: SignInWithApplePlugin;
              ~~~~~~~~~~~~~~~
    'SignInWithApple' is declared here.

[ERROR] An error occurred while running subprocess ng.

How to prevent "registerWebPlugin" for iOS?

So the docs say we need to execute

registerWebPlugin(SignInWithApple);

but is this only for the web?

If the user uses the plugin on iOS capacitor app, what is the recommended way to not execute registerWebPlugin(SignInWithApple); for that case?

getDeviceInfo is async, so it's not ideal right?

clientId not set?

First, thanks for this great plugin! I am using it on both Web and iOS.

Everything works great on Web. It almost works on iOS, but the error I get when trying to make use of the returned identityToken is "client_id mismatch. The code was not issued to xxx.xxx"

Debugging inside Plugin.swift, I can see that the call object has call.options["clientId"] set correctly to my app's client_id. However I cannot see anywhere that Plugin.swift makes use of this value? It doesn't seem to set it on the request that gets sent to Apple?

Update this plugin for Capacitor 3

Capacitor 3 is being built and is already in beta. In this new version the native plugins have been removed from the core and there are some changes that are necessary in the existing plugins.

Example: Plugin Imports
The Plugins object is deprecated, but will continue to work in Capacitor 3. Capacitor plugins should be updated to use the new plugin registration APIs (see the Upgrade Guide for plugins), which will allow them to be imported directly from the plugin’s package.

Going forward, the Plugins object from @capacitor/core should not be used.

// OLD
import { Plugins } from '@capacitor/core';
const { AnyPlugin } = Plugins;
Importing the plugin directly from the plugin’s package is preferred, but the plugin must be updated to work with Capacitor 3 for this to be possible.
// NEW
import { AnyPlugin } from 'any-plugin';

References:

Updating Capacitor to 3.0 in your plugin

Updating Capacitor to 3.0 in your app

(credits to @mklipe for issue explanation)

New requirements for gradle 8

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @capacitor-community/[email protected] for the project I'm working on.

Please replace the package attribute in AndroidManifest.xml with the namespace attribute in build.gradle cause is required by gradle 8.

Here is the diff that solved my problem:

diff --git a/node_modules/@capacitor-community/apple-sign-in/android/build.gradle b/node_modules/@capacitor-community/apple-sign-in/android/build.gradle
index 237ba31..724fe7c 100644
--- a/node_modules/@capacitor-community/apple-sign-in/android/build.gradle
+++ b/node_modules/@capacitor-community/apple-sign-in/android/build.gradle
@@ -17,6 +17,7 @@ buildscript {
 apply plugin: 'com.android.library'
 
 android {
+    namespace "com.getcapacitor.community.applesignin.applesignin"
     compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
     defaultConfig {
         minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
diff --git a/node_modules/@capacitor-community/apple-sign-in/android/src/main/AndroidManifest.xml b/node_modules/@capacitor-community/apple-sign-in/android/src/main/AndroidManifest.xml
index 22b7aa9..9957c84 100644
--- a/node_modules/@capacitor-community/apple-sign-in/android/src/main/AndroidManifest.xml
+++ b/node_modules/@capacitor-community/apple-sign-in/android/src/main/AndroidManifest.xml
@@ -1,5 +1,4 @@
 
-  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-      package="com.getcapacitor.community.applesignin.applesignin">
+  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
   </manifest>
   
\ No newline at end of file

This issue body was partially generated by patch-package.

Uses non-standard Capitalisation for the API

The plugin exposes a .Authorize()method, this is Capitalised and thus non-standard, it might be useful to rename it to .authorize() to keep it standardised. This would necessitate a major-version bump as it's a breaking change.

Value of type 'CAPBridge' has no member 'saveCall'

I've come to my project again after a few months and now am now getting the following when trying to build.

Can someone point me in the direction of what might have happened? I've not updated any version dependencies directly (although, I did yarn and then cap sync).

image

Worth noting, I was having issues with cap sync initially and did have to change the minVersion for iOS to 12 from 11, despite me not changing anything.

Apple Sign in on web in localhost

Describe the bug
I have this working on an iOS device fine but when attempting to use apple log in while developing on http://localhost:8100 it just tells me that i have an "invalid_request - Invalid web redirect url."

What am I doing work?

const options: SignInWithAppleOptions = {
  clientId: 'com.myapp',
  redirectURI: 'http://localhost:8100/login',
  scopes: 'email name',
  // state: '1256',
  state: '12345',
  nonce: hashedNonceHex,
};
const appleUser: SignInWithAppleResponse = await SignInWithApple.authorize(options);`

image

Node js backend example

Hi everyone,
I'm implementing this library inside my ionic capacitor application and I have a question.
Is there an example, possibly written in node js, describing a backend that responds to the redirectURI? I create a services id on Apple Developer Dashboard, but seems that the redirectURI is never called.

Thanks to all

iOS redirectURI

I have no idea what to do to get this to work in iOS and Capacitor 2.0. It appears I have to include the redirectURI otherwise nothing happens when I invoke authorize. And yet if I include something (which is inevitably incorrect as this is an app, not a website) the app opens an external browser to report "Invalid URI". I'm so desperate, I'd Venmo someone a thank you if I could get this up and running.

Resetting Apple id logins doesn't work

Describe the bug
Resetting the apple id logins doesn't seem to have any effect on the dialog the OS is presenting after subsequent authorization attempts. It shows up the same one as for the login.

To Reproduce
Steps to reproduce the behavior:

  1. authorize the apple signin
  2. remove the apple id login permission for the app
  3. attempt to re-authorize the app. the dialog is one the os is showing for login screen not for authorize ( with choosing the full name and email option to show/hide ).
  4. as a result, the fullname and email is not returned upon login.

Desktop (please complete the following information):

  • OS: Catalina
  • Version 10.15.7

Smartphone (please complete the following information):

  • Device: iphone 6s
  • OS: ios 14.6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.