# Regarding auth flow of email and scheduler

**URL:** <https://forums.nylas.com/t/regarding-auth-flow-of-email-and-scheduler/365>\
**Category:** Question and Answers\
**Tags:** authentication, scheduler\
**Created:** [August 21, 2024, 12:54pm UTC](https://forums.nylas.com/t/regarding-auth-flow-of-email-and-scheduler/365 "2024-08-21T12:54:12Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![dhruv](https://avatars.discourse-cdn.com/v4/letter/d/7c8e57/32.png) [@dhruv](https://forums.nylas.com/u/dhruv)\
**Post date:** [August 22, 2024, 4:27am UTC](https://forums.nylas.com/t/regarding-auth-flow-of-email-and-scheduler/365/6 "2024-08-22T04:27:26Z")

</div>

@Blag it will work for html/vanila js also right ?  
but when i tried to bypass it through that it send me this error

 ![image](https://us1.discourse-cdn.com/flex015/uploads/nylas3/original/1X/4e8eed074e8a95b28c308474cc05782b9e6c8715.png)

here is my code for ref:

```auto
    <div class="grid h-full place-items-center">
      <!-- Add the Nylas Scheduler Editor component -->
      <nylas-scheduler-editor 
        />
      </div>

    <!-- Configure the Nylas Scheduler Editor component -->
    <script type="module">
              class CustomIdentityRequestWrapper {
            constructor(accessToken) {
                this.accessToken = accessToken;
            }

            async request(args) {
                try {
                    console.log('args', args);
                    console.log('args method',args.method)
                    const response = await fetch(`https://api.eu.nylas.com/v3/grants/me/${args.path}`, {
                      mode:"no-cors",
                        method: args.method,
                        body: JSON.stringify(args.body),
                        headers: {
                          ...args.headers,
                          'Authorization': `Bearer ${this.accessToken}`,
                          'Content-Type': 'application/json',
                          'Access-Control-Allow-Origin': '*',
                        },
                    });

                    if (!response.ok) {
                        console.error(`Error: ${response.status} ${response.statusText}`);
                        return { error: `Error: ${response.status} ${response.statusText}` };
                    }

                    const data = await response.json();
                    return [data, null];
                } catch (error) {
                    console.error('Fetch error:', error);
                    return { error: "Error" };
                }
            }

            async currentUser() {
                return {
                    id: 'eyJhbG................................',
                    email: 'dhruv...............',
                    name: 'dhruv',
                    provider: 'google',
                };
            }

            async setDefaultAuthArgs(authArgs) {
                return authArgs;
            }

            async authenticationUrl() {
                return 'http://localhost:3000/scheduler-editor';
            }
        }
        // const schedulerEditor = document.querySelector("nylas-scheduler-editor");
        // schedulerEditor.schedulerPreviewLink = `${window.location.origin}/?config_id={config.id}`;

        const accessToken = 'BI6A3fKRLxJNEzHXXixvMExqrYRMSEKKHhSpvbWoiJytFm07bvCObTc2r1Tc2305_kpL_9_9.......................................................................'
        // Create an instance of the CustomIdentityRequestWrapper class defined above
        const schedulerEditor = document.querySelector("nylas-scheduler-editor");
        const nylasApiRequest = new CustomIdentityRequestWrapper(accessToken)
        schedulerEditor.nylasApiRequest = nylasApiRequest

      schedulerEditor.schedulerPreviewLink = `${window.location.origin}/?config_id={config.id}`; // Replace with the URL of the page where you want to display the scheduler
      schedulerEditor.configurationId = "config.id"; // Replace with the configuration ID you want to edit
      // schedulerEditor.nylasSessionsConfig = {
      // clientId: "91d00.......................................", // Replace with your Nylas client ID from nylas dashboard
      // redirectUri: `${window.location.origin}/scheduler-editor`, // Replace with the redirect URI you set in the Nylas dashboard
      // domain: "https://api.eu.nylas.com/v3", // or 'https://api.us.nylas.com/v3' for US data center
      // hosted: true,
      // accessType: "offline", 
      // };
      
      schedulerEditor.defaultSchedulerConfigState = {
        selectedConfiguration: {
          requires_session_auth: false, // creates public configuration which does not require session tokens
          scheduler: {
            // organizer_confirmation_url: `${window.location.origin}/confirmation/:booking_ref`,
            cancellation_url: `${window.location.origin}/cancel/:booking_ref`,
            rescheduling_url: `${window.location.origin}/reschedule/:booking_ref`,
            // confirmation_redirect_url: `${window.location.origin}/booking-confirmed`
          },
        },
      };

```

in above code i have used hard coded values as of now for testing auth but it didn’t worked out do i missing something or is there any mistake from my side ??

---

_[View the full topic](https://forums.nylas.com/t/regarding-auth-flow-of-email-and-scheduler/365)._
