Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add user login? #7

Closed
Catzoy opened this issue Jul 13, 2020 · 11 comments
Closed

How to add user login? #7

Catzoy opened this issue Jul 13, 2020 · 11 comments
Labels
question Further information is requested

Comments

@Catzoy
Copy link

Catzoy commented Jul 13, 2020

In step 2 of "Getting Started" our app must add a callback activity for user OAuth login with some "redirect URL", yet it is unclear what redirect URL must do and who provides such URL.
Please explain how to add user authorization to the app.

@fabriciovergara
Copy link
Contributor

fabriciovergara commented Jul 13, 2020

Hi @Catzoy

Sorry for the lack if details, there is still a work in progress regarding the integration process and documentation.

In the https://developer.izettle.com/ after you create a Payments Android SDK credential you will be prompted to add the redirect URI. In the app, after user finish an authentication (which happen in a browser) we still redirect to this URI and the sdk will handle the result.

We suggest to not use https since it's really specific for iZettle login for your app and we would like to not have deep link conflict with other apps, in the same way when you share a photo and you are prompted to choose which app will handle it.

If you choose this redirect URI:

Screenshot 2020-07-13 at 15 29 33

Then in our sample you must fill the iZettleSDK.gradle with this:

Screenshot 2020-07-13 at 15 39 23

Please, let us know if you have any problem.

@fabriciovergara fabriciovergara added the question Further information is requested label Jul 13, 2020
@Catzoy
Copy link
Author

Catzoy commented Jul 14, 2020

Hi @fabriciovergara

Thank you for quick response!

Issue was that we didn't add any OAuth Redirect URI in the https://developer.izettle.com/ for our app and that's why SDK always returned "redirect_url contains not allowed URI" for anything we tried.

Closing issue as resolved.

@Catzoy Catzoy closed this as completed Jul 14, 2020
@remitettiravou
Copy link

Hi,

@fabriciovergara you said the SDK "will handle the result" when redirected in redirect URL.
In my app, after login in the browser, I see the access_token (displayed from my redirect_uri), and that's all, nothing else is happening. How do we return to the application with the access_token taken into account ?

Thanks

Rémi

@fabriciovergara
Copy link
Contributor

@remitettiravou

After the login, the browser will be redirect to the deep-link registered in your app manifest:

<activity 
    android:name="com.izettle.android.auth.OAuthActivity" 
    android:launchMode="singleTask"
    android:taskAffinity="@string/oauth_activity_task_affinity"> 
    <intent-filter> 

        <!-- Deep link data -->
        <data 
            android:host="izettlelogin"  
            android:scheme="izettlesample />
       

       <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
    </intent-filter>
</activity>

Please, check if the values are correct and the same as declared in the developer portal.

@remitettiravou
Copy link

I used to have https scheme. Now with "app" scheme and my Activity for host, it is working. Thanks.

@Olmectron
Copy link

Olmectron commented Oct 3, 2020

I'm getting the message:

Invalid protocol, can not start with "izettle" or be one of http:// or file://.

When trying to put izettlesample://izettlelogin in the OAuth Redirect URIs list.

Has the correct redirect URI changed by now?

@atsneves
Copy link

@Olmectron please not use in the scheme the words http or izettle

@crashfiredeep
Copy link

Hi @Catzoy

Sorry for the lack if details, there is still a work in progress regarding the integration process and documentation.

In the https://developer.izettle.com/ after you create a Payments Android SDK credential you will be prompted to add the redirect URI. In the app, after user finish an authentication (which happen in a browser) we still redirect to this URI and the sdk will handle the result.

We suggest to not use https since it's really specific for iZettle login for your app and we would like to not have deep link conflict with other apps, in the same way when you share a photo and you are prompted to choose which app will handle it.

If you choose this redirect URI:

Screenshot 2020-07-13 at 15 29 33

Then in our sample you must fill the iZettleSDK.gradle with this:

Screenshot 2020-07-13 at 15 39 23

Please, let us know if you have any problem.

I have also followed same and login is working redirecting to app but never able to see access token and refresh token in onActivityResult(). but what about access token as mentioned in documentation??

But i can see the log like
2023-01-03 11:42:51.144 25633-25700/com.pospal.pospal I/TokenRepositoryImpl: [{userId=3f329550-70fb-11e5-a847-bda5b59ed83f, tokens=OAuthTokens(accessToken=eytg, refreshToken=IZ89, expirationDate=Tue Jan 03 13:42:50 GMT+05:30 2023, scopes=[READ:PAYMENT, READ:USERINFO, WRITE:PAYMENT])}]
at com.izettle.android.auth.log.StackTraceKt.withStackTrace(SourceFile:1)
at com.izettle.android.auth.TokenRepositoryImpl$applyStoreTokensToTransaction$1.invoke(SourceFile:3)
at com.izettle.android.auth.TokenRepositoryImpl$applyStoreTokensToTransaction$1.invoke(SourceFile:1)
at com.izettle.android.auth.storage.Transaction.commit(SourceFile:27)
at com.izettle.android.auth.tasks.OAuthLoginTask.finalizeTask(SourceFile:10)
at com.izettle.android.auth.tasks.OAuthAuthTask$resume$1.invoke(SourceFile:15)
at com.izettle.android.auth.tasks.OAuthAuthTask$resume$1.invoke(SourceFile:1)
at com.izettle.android.auth.executor.ExecutorImpl.schedule$lambda-3(SourceFile:2)
at com.izettle.android.auth.executor.ExecutorImpl.$r8$lambda$ApSXqycmJTVshYvryZVW9t0bXko(Unknown Source:0)
at com.izettle.android.auth.executor.ExecutorImpl$$ExternalSyntheticLambda0.run(Unknown Source:8)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:233)
at android.os.Looper.loop(Looper.java:334)
at android.os.HandlerThread.run(HandlerThread.java:67)
2023-01-03 11:42:51.216 25633-25633/com.pospal.pospal I/XDR::VRT: sc is not valid!

@CheZhongSdk
Copy link
Collaborator

CheZhongSdk commented Jan 3, 2023

@crashfiredeep Not sure I understand your question correctly. But you don't get the AccessToken or RefreshToken in the onActivityResult(). Instead, you should observe the authentication state. Please see this.

Here is the example code in Example project. (https://github.com/iZettle/sdk-android/blob/master/Examples/Example-Kotlin/app/src/main/java/com/izettle/payments/android/kotlin_example/MainActivity.kt#L33)

@crashfiredeep
Copy link

@crashfiredeep Not sure I understand your question correctly. But you don't get the AccessToken or RefreshToken in the onActivityResult(). Instead, you should observe the authentication state. Please see this.

Here is the example code in Example project. (https://github.com/iZettle/sdk-android/blob/master/Examples/Example-Kotlin/app/src/main/java/com/izettle/payments/android/kotlin_example/MainActivity.kt#L33)

that is already implemented but if logged in states of login is also coming false, and what if I need to access payment flow using token. in these methods there is no way to get token and refresh token. My app is need to login every time for payment, so I want to store the token and process further based on this token, so that user only need to login once.

@bobzettle
Copy link
Contributor

Hi @crashfiredeep, the SDK doesn't expose the tokens and we have no plan of doing so.
Today there are two ways of authenticating the SDK.

  • The SDK handles everything, you just tell it to log in.
  • You handle authentication and provide a refresh token that the SDK can use to fetch access tokens when needed. When doing a refund a UI will be triggered to verify the credentials.

Both of the above methods will keep the user logged in as long as the tokens are valid. So if you don't explicitly log out the user you should not be prompted to log in on every payment. The tokens are valid for quite some time.

As a side note.
We are also working on a third way where the integrator is in full control over the tokens and the SDK will only ask for tokens when needed leaving the integrator in full control. But we don't have a release date for this yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

8 participants