•   almost 11 years ago

I need working script for Spicwork API session login(Urgent Please)

Any Developer in the house.
Please I need to create session Login using Spicywork API but the Code is some how scattered, can someone please help provide a full working Session based Login Code that will redirect a user to my welcome page.

below is how i tried to reassemble the login code.
http://fredcare.com/spicy_session_login.txt

Can you please help me fix the issue to make things easier for me and others

Again i will need an explanation on how the following variables are obtained whether from my System or from Spicework API.

auid: environment.app_host.auid,
user_auid: environment.user.user_auid,
access_token: access_token

please help me fix this login code

Thanks.

  • 2 comments

  • Manager   •   almost 11 years ago

    Hi chinelo,

    This document contains a description of the authentication process: https://spiceworks.github.io/developers.spiceworks.com//documentation/cloud-apps/authentication/.

    You'll notice in step 2: https://spiceworks.github.io/developers.spiceworks.com//documentation/cloud-apps/authentication/#step-2:-obtain-an-oauth2-access-token, that it will require a unique ID from your App. The next version of Spiceworks: Developer Edition will generate this automatically. However, in the meantime, you'll need to contact us at appcenter@spiceworks.com to get your unique App ID and secret.

    Once you have your App ID and secret, you should be able to follow the documentation.

    To highlight some of the stuff covered in the documentation:
    From Step 1: Here is how to obtain those first two variables and print them to the JS console (no App ID necessary):

    var card = new SW.Card();
    card.services('environment').request('environment').then(
    function(environment){
    console.log(environment.app_host.auid, environment.user.user_auid);
    ));

    From Step 2: The access_token can be obtained with the following code:

    var login = new SW.Login({appUid: "your-oauth2-application-id"});
    login.request('login').then(
    function(access_token){
    /* success! */
    console.log(access_token);
    },
    function(errors){
    /* oh no! */
    });

    Again, to get the Access Token, you will need a unique App ID, which you will need to contact us for privately.

    Let me know if you have any other questions.

    Mike

  • Manager   •   almost 11 years ago

    Hi, we have added a simple form you can submit to request an App ID and Secret, so that you can start using the Spiceworks Login API to test user authentication: http://www.surveygizmo.com/s3/2206835/Challenge-Post-Access-Token-Request.

Comments are closed.