how get user login in gadget?

dr6den dr6den July 3, 2011

I read http://wiki.customware.net/repository/display/ATLASSIAN/Writing+an+Atlassian+Gadget and somethisng not clear. How can I get login of current user in gadget.xml? Perhaps silly question.

AJS.Gadget({
baseUrl: ...,
useOauth: ...,
config: ...,
view:...
});
It looks
useOauth is responsible for it . Thanks for attention

5 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 3, 2011
useOauth is not for getting user details but for enforcing the authorization mechanism to use while the user access a gadget.

A value of always means, everone can access the gadget whereas a value /rest/gadget/1.0/currentUser will use JIRA's Oauth service to do the authentication.

You can get the current user details using the same rest service: /rest/gadget/1.0/currentUser
Chris Stamp June 4, 2015

Where is this info where it states different property values for the useOauth property in the gadget?

0 votes
dr6den dr6den July 5, 2011

could you show full gadget xml of example http://www.j-tricks.com/1/post/2011/04/invoking-rest-services-from-gadgets.html, I think something wrong in my code, that I havent yet understood.

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 5, 2011

I have attached the full plugin in the post now. Have a look. Hope it helps!

0 votes
dr6den dr6den July 4, 2011

Thanks useful post.

All such interesting and clear.

I tried this piece of code but code cant send query,

I tried past to browser

/rest/gadget/1.0/currentUser and it works I got responce. But from gadget.xml I cant send and receive query. 
I tried simply get and its doesnt work too

<Content type="html" view="profile">
<![CDATA[
<div id="hope"/>
#requireResource("com.atlassian.jira.gadgets:common")
#includeResources()
<input type="button" id="art"></input>
<script type="text/javascript">

jQuery(document).ready(function(){
jQuery("#art").click(function() {
jQuery.get("/jira/plugins/servlet/children", {"parentid":"3"}, function(data) {
});
});
});
</script>
]]>
</Content>

looks like that gadget.xml cant send querys. firebug show that query wasnt send when button was pressed
0 votes
dr6den dr6den July 3, 2011

Im not familiar with ajs, thats why I search the example of simple code

that allows me do such:

<script type='text/javascript'>

...

{code of retrieving login of current user}

...

login = ...

</script>

that is all in gadget.xml exact

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 3, 2011

I hope you mean retrieving current user's details like name etc. Have a look at this post. Hope it helps.

0 votes
dr6den dr6den July 3, 2011

sorry I didnt understand exactly

Whats wrong in this script

<![CDATA[
            <script type="text/javascript">
                (function () {
            var gadget = AJS.Gadget({
            baseUrl: "__ATLASSIAN_BASE_URL__",
            view: {
            template: function(args) {
                var gadget = this;
                                },
            args: [{
                key: "quip",
                ajaxOptions: function() {
                    return {
                        url: "/rest/gadget/1.0/currentUser",
                        data:
                                                     {
                                                         key : this.getPref("key")
                                                     }
                    };
                }
            }]
            }
            });
            })();
                        alert(args.data.key);
                        
            </script>
        ]]>

Why cant I get args.data.key?

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 3, 2011

Not sure if I understood correctly what are you trying to do here? What is it that you are passing to the the REST service? I don't think it takes any inputs.

Are you trying to retrieve the current user details? Like name etc?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events