• Resolved eljara

    (@sawasblog)


    First of all, Thank you for the great app !!

    I have an android app associated with my wordpress blog, i have added the firebase auth , but i need to link social accounts with my wordpress members after creation of new users , any help will be appreciated .

    thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Ramona

    (@nextend_ramona)

    Hi @sawasblog

    Here are some information about the endpoint of Nextend Social Login and the way you can use it in the app you develop on your own.
    Before continuing please note that we can not provide support for custom coding!

    The part of the registration that Nextend Social Login can help you with is checking if there’s any user in your site who has already registered with the currently used social account.

    Let’s say someone tries to register/login via Google. This is the process you’ll need to achieve

    1) Communication between the user and your mobile app
    You need to create a way for the user to communicate with Google API. (Basically a way to display the authorization window, something like: https://imgur.com/TMrYizZ )
    This will result you having an access token.

    2) “User validation”
    Once you have the access token you can use this to communicate with Nextend Social Login (NSL) which will check whether there’s any user registered to your site with the given access token.
    Nextend Social Login REST Api endpoints:
    Method: POST
    /wp-json/nextend-social-login/v1/google/get_user

    For example:
    https://example.com/wp-json/nextend-social-login/v1/google/get_user
    the file itself can be found here: wp-content/plugins/nextend-facebook-connectNSL/REST.php if you would like to check it.

    POST Args:
    access_token > NSL needs the access token as a JSON, like these: https://gist.github.com/nextend/b733d402ee2e2cee59b632f6e4741a9d

    Here you can find a Test form to post your access token, what you can use to check if your access token is correct and if there is a user with that access token
    https://gist.github.com/nextend/4d3c701c8d99972824025e4dfdeccac0
    please note that you need to replace the “xyz.com” with your domain.

    Once the Access Token is posted the endpoint can return:

    * Success -> status 200 -> json encoded WP user id, for example: “44”
    * Fail -> if the status code isn’t 200 then an error happened -> For example: {“code”:”error”,”message”:”The access token could not be decrypted”,”data”:null}

    3a) Access token found – Login process
    If NSL returns the WordPress user ID you’ll need to log them in to your mobile app.

    3b) Access token not found – Registration process

    If NSL did not find any user with the given access token, you need to create a new WordPress user using WordPress’ REST API. Then log them in and you can link the user with the social provider.

    These codes can be helpful at the 3rd step: https://gist.github.com/nextend/012ca54957e27dbea952fc42195fb0d1
    for linking the social account to the WordPress user.
    line 1-11: will verify that the access token is valid, if it is valid it will retrieve the social user id ( this ISN’T the WordPress user id! )
    line 13-16: will connect the social provider account with the WordPress user ID.

    Thread Starter eljara

    (@sawasblog)

    Thank you Ramona for your great help , a lot of things are now clear for me , but i
    still have a question about 3a) Access token found – Login process

    How can i login user with the token ?

    I am using a plugin for authentication via REST API (JWT Authentication for WP REST API) and user provide either username and password , or an access token if he is logged in before .

    How can i login via REST API using social account tokens

    Plugin Support Laszlo

    (@laszloszalvak)

    Hi @sawasblog

    Please note that we can not provide support for custom coding, but here some useful information:

    If our REST API can find a user with the posted access token, then it will return the ID of the user.
    This ID could be used for:

    Thread Starter eljara

    (@sawasblog)

    Google

    {“access_token”:”xxxxxxxxx”,”expires_in”:3600,”id_token”:”xxxxxxxxx”,”token_type”:”Bearer”}

    what is the difference between access_token and id_token here ?

    In this documentation
    https://firebase.google.com/docs/auth/admin/verify-id-tokens

    i found how to get the id_token i guess , but how can i find access token for google , thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can i use the login functionality with my android app’ is closed to new replies.